Next.js Discord

Discord Forum

Multiple modals opening

Unanswered
Blue Picardy Spaniel posted this in #help-forum
Open in Discord
Blue Picardy SpanielOP
const searchParams = useSearchParams();
const hasRun = useRef(false);

useEffect(() => {
  // Open edit modal if visits page with ID in url
  if(searchParams.get("id") === globalBan._id && !hasRun.current) {
    hasRun.current = true;
    openEdit();
    console.log("opened");
  }
}, []);

Why are two modals being opened when I visit my page with an ID in the URL?

0 Replies