I wasn't able to find an answer for this. I'm using TS to build some Components in React, the thing is I'm working with Component Framework and whenever I try to send the props to a Function Component, if I try to use them, I get the next error:
Property 'text' does not exist on type '{ children?: ReactNode; }'.
The code is like this: The props declaration:
public props: IFirstButton = {
text: "",
entity: "",
selectedField: "",
context: null,
onChangeText: this.onChangeText.bind(this)
};
Here is the calling to the Component:
ReactDom.render(
React.createElement(AppComponentExample, this.props),
this._container
)
The Component calling Function Component:
public render(): JSX.Element {
return (
<React.Fragment>
<PanelBasicExample {...this.props} ></PanelBasicExample>
</React.Fragment>
);
}
And finally, the Function Component:
export const PanelBasicExample: React.FunctionComponent = (props) => {
const [isOpen, { setTrue: openPanel, setFalse: dismissPanel }] = useBoolean(false);
const searchText: any = "Selector Cuenta Bancaria" || props.text;
console.log(props);
const panelStyles: Partial<IPanelStyles> = {
main: {
alignContent: "center",
'@media(min-width: 480px)': {
width: "100%",
position: "absolute",
overflow: "hidden auto",
}
},
header: {
width: "100%",
textAlign: "center"
}
}
const panelStyle = {
height: "80%",
left: "25%",
right: "25%"
}
return (
<div>
<DefaultButton text={searchText} onClick={openPanel} />
<Panel
headerText="Selector Cuenta Bancaria"
isOpen={isOpen}
onDismiss={dismissPanel}
// You MUST provide this prop! Otherwise screen readers will just say "button" with no label.
closeButtonAriaLabel="Cerrar"
style={panelStyle}
styles={panelStyles}
>
<TableExample {...props}></TableExample>
</Panel>
</div>
);
};
PD: That console log logs what I'm expecting (the correct object with the data I need)