I am fairly new to the react. I've browsed many threads with similar questions, followed instructions but can't crack this one: I have an parent component which opens dialog window but I cannot handle closing. I am using the sap UI5 library but I feel the issue is purely react related
- In parent I have
const ExecutionsTable = () => {
const [executionDialogIsOpen, setExecutionDialogIsOpen] = useState(false);
const handleOpenExecutionDetailsClick = () => {
setExecutionDialogIsOpen(true);
};
return (
<>
<Button
onClick={() => {
handleOpenExecutionDetailsClick(true);
}}
>
Details
</Button>
{<ExecutionDialog setExecutionDialogIsOpen={setExecutionDialogIsOpen}/>}
</>
);
}
- In child component
const ExecutionDialog = (props) => {
return (
<Dialog
open={props.executionDialogIsOpen}
onAfterClose={() => props.setExecutionDialogIsOpen(false)}
/>
);
}
I am getting error:
ExecutionDialog.js:35 Uncaught TypeError: props.setExecutionDialogIsOpen is not a function
at Dialog.onAfterClose (ExecutionDialog.js:35:1)
at Dialog._fireEvent (UI5Element.js:732:1)
at Dialog.fireEvent (UI5Element.js:699:1)
at Dialog.close (Popup.js:511:1)
at HTMLDocument._keydownListener (OpenedPopupsRegistry.js:38:1)
onAfterClose @ ExecutionDialog.js:35
_fireEvent @ UI5Element.js:732
fireEvent @ UI5Element.js:699
close @ Popup.js:511
_keydownListener @ OpenedPopupsRegistry.js:38
Can you please guide me on what am I doing wrong? Many thanks.