Closed osrl closed 9 months ago
hmm, I remember calling modal.show(modal, args)
can use any prop name.
Just tried and it works but with typescript error.
Need to fix the type check of modal.show()
.
export const MyAntdModal = NiceModal.create(({ name , id}: { name: string, id: string }) => {
const modal = useModal();
return (
<Modal title="Hello Antd" visible={modal.visible} onOk={modal.hide} onCancel={modal.hide} afterClose={modal.remove}>
Greetings: {name} ({id})!
</Modal>
);
});
export default function AntdSample() {
return (
<Space>
<Button type="primary" onClick={() => {
//@ts-ignore
NiceModal.show(MyAntdModal, { name: 'Nate', id: 'nateid' })}
}>
Show Modal
</Button>
</Space>
);
}
Hi @supnate any luck with this?
@supnate I'm using 1.2.13 and still facing the same problem. typescript still reports error because I passed id prop as number type
NiceModalHocProps has a field named id. This is too common and prevents us to pass a type with id in it.
This is not possible:
I actually opened a PR for this #96. But closed it since it wasn't backward compatible.
To reproduce: