Next.js Discord

Discord Forum

changing states in sequence

Unanswered
Japanese pilchard posted this in #help-forum
Open in Discord
Japanese pilchardOP
Hi guys I wanna change two different states in next but one by one, if I just put them in order they don't change sequence ly

2 Replies

Common paper wasp
I can give you an awkward solution, but don't tell anyone that was my idea

setStateOne();
setTimeout(() => {|
setStateTwo()
}, 0)

Due to eventloop and some react render process it should execute in sequence
But I should worry that you should look into your app architecture, cause if you looking for thinks like this, you definetly have some issues in app