Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defaultVisible #150

Open
Staskasnz opened this issue Mar 21, 2024 · 2 comments
Open

defaultVisible #150

Staskasnz opened this issue Mar 21, 2024 · 2 comments

Comments

@Staskasnz
Copy link

Staskasnz commented Mar 21, 2024

Hello, I can’t seem to pass the "true" value in defaultVisible to a created and registered modal window, how can I do this correctly?
Typescript suggests exactly this method, but no matter how hard I try, I can’t pass the defaultVisible value

const DesktopMenu = loadable(
  () => import('src/entities/menu').then((mod) => mod.DesktopMenu),
  {
    ssr: false,
  }
);

const DesktopMenuWithProps = NiceModal.create(DesktopMenu);

const registar = () => {
  NiceModal.register('desktop-menu', DesktopMenuWithProps, {
    defaultVisible: true,
  });
};

export const ModalProvider: React.FC = ({ children }) => {
  registar();
  return <NiceModal.Provider>{children}</NiceModal.Provider>;
};
@supnate
Copy link
Collaborator

supnate commented Mar 24, 2024

defaultVisible is only useful with declarative way: <MyNiceModal defaultVisible .../>

Also, register is expected to be called only once for a modal, don't use it inside a component.

However, to make a modal default visible, you can also use NiceModal.show after registration.

@andyyxw
Copy link

andyyxw commented Apr 9, 2024

defaultVisible is only useful with declarative way: <MyNiceModal defaultVisible .../>

Also, register is expected to be called only once for a modal, don't use it inside a component.

However, to make a modal default visible, you can also use NiceModal.show after registration.

@supnate I don't know how to use defaultVisible in any NiceModal api,can you provide an example for modal default open scene? It seems that because I haven't manually execute the modal.show() , so modal has not mounted at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants