我对这种反应相当陌生。我浏览过许多类似问题的线程,遵循说明,但无法破解这个问题:我有一个打开对话框窗口的父组件,但无法处理关闭操作。我正在使用sap UI5库,但我觉得这个问题纯粹是与反应相关的。
const ExecutionsTable = () => {
const [executionDialogIsOpen, setExecutionDialogIsOpen] = useState(false);
const handleOpenExecutionDetailsClick = () => {
setExecutionDialogIsOpen(true);
};
return (
<>
<Button
onClick={() => {
handleOpenExecutionDetailsClick(true);
}}
>
Details
</Button>
{<ExecutionDialog setExecutionDialogIsOpen={setExecutionDialogIsOpen}/>}
</>
);
}子组件
const ExecutionDialog = (props) => {
return (
<Dialog
open={props.executionDialogIsOpen}
onAfterClose={() => props.setExecutionDialogIsOpen(false)}
/>
);
}我正在犯错误:
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你能告诉我我做错了什么吗?非常感谢。
发布于 2022-10-28 14:38:47
我已经知道了,ExecutionDialog组件应该是这样的:
<ExecutionDialog setExecutionDialogIsOpen = {setExecutionDialogIsOpen} executionDialogIsOpen = {executionDialogIsOpen}/>https://stackoverflow.com/questions/74225299
复制相似问题