Next.js Discord

Discord Forum

Open modal better approach

Unanswered
Berylline Hummingbird posted this in #help-forum
Open in Discord
Berylline HummingbirdOP
Hey guys, new react user here.
was wondering about something on a project im working on...

let's say i have a page which sends a ajax request every 3 seconds to the server, the server returns JSON and one property should be changing from false to true,
once it hits true i want to show a modal on the screen, but i want the user to be able to close the modal.

so if i will check on the code if the value is true it will keep opening non stop.

what is the best way to achieve opening the modal once when it detects true?
i can create a state variable to check if it was closed but i assume there is a better way to achieve it.

would love to learn 🙂 thanks!

0 Replies