After upgrading to React 18 I have the following issue with Antd.
When using a component from Antd (Modal, Dialog, ...) it gives me this error:
TS2322: Type '{ children: ReactNode; ref: ForwardedRef<unknown>; className: string; visible: true; onCancel: (() => void) | undefined; onOk: undefined; footer: null; closable: false; }' is not assignable to type 'IntrinsicAttributes & ModalProps'. Property 'children' does not exist on type 'IntrinsicAttributes & ModalProps'.
Here is my component:
function TransitionsModal(props: Props): JSX.Element {
const {
open,
onClose,
children
} = props;
return (
<div>
{open &&
<Modal
className="flex items-center justify-center"
visible={open}
onCancel={onClose}
onOk={undefined}
footer={null}
closable={false}>
{children}
</Modal>
}
</div>
);
}
And here my Props:
type Props = {
children: React.ReactNode,
open: boolean,
onClose?: () => void
}
I use node 17.8.0
you should use
"@types/react": "17.0.39"
instead of
"@types/react": "18.0.3"
because react18 @types is not yet compatible.