eBay / nice-modal-react

A modal state manager for React.
https://ebay.github.io/nice-modal-react
MIT License
1.96k stars 109 forks source link

Antd "visible" prop is deprecated, use "open" instead #136

Closed AlmazHecker closed 7 months ago

AlmazHecker commented 7 months ago

here's the fix

export const antdModal = (
  modal: NiceModalHandler,
): { open: boolean; onCancel: () => void; onOk: () => void; afterClose: () => void } => {
  return {
    open: modal.visible,
    onOk: () => modal.hide(),
    onCancel: () => modal.hide(),
    afterClose: () => {
      // Need to resolve before remove
      modal.resolveHide();
      if (!modal.keepMounted) modal.remove();
    },
  };
};
supnate commented 7 months ago

For antd v5, use andV5 helper. We need to be compatible with antd v4.