#Modals manager doesn't open modal

4 messages · Page 1 of 1 (latest)

simple mist
#

I am trying to open modal inside ProtectedRoute wrapper but it doesn't work

export const ProtectedRoute = ({ children }: { children: ReactElement }) => {
  const { isLogged } = AuthConsumer();

  if (isLogged) {
    return children;
  }

  openModal({
    title: "Login",
    children: (
      <Login
        onClose={() => {
          closeAllModals();
        }}
      />
    ),
  });

  return <Navigate to="/" replace />;
};

I am not able to show full example, as in my case modals doesn't work on sandbox..

#

when I move openModal inside useEffect it opens modal but weirdly I have to click 2 times to close it 🤔

mortal spoke
simple mist
#

I think I can live with that, but there is still question why it doesn't work without useEffect