Thanks for sharing!
I'm curious about this line
Promise.resolve().then(()=> raw.isRendering = false)
What guarantees do we have that the promise will only resolve in the commit phase of React?
As far as I'm aware, only useLayoutEffect is guaranteed to be ran once in the commit phase. See this video: youtube.com/watch?v=V1Ly-8Z1wQA at 16:05.
useLayoutEffect
If that's correct, then we could change it to something like:
raw.isRendering = true; raw.currentValue = raw.comittedValue; useLayoutEffect(() => { raw.isRendering = false; raw.comittedValue = raw.currentValue; });
And I think that would work together better with React's guarantees. What do you think?
Agree 👍 Also, if we assume this, what happens to time slicing?
This doesn't work guys. Have you tested it?
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks for sharing!
I'm curious about this line
What guarantees do we have that the promise will only resolve in the commit phase of React?
As far as I'm aware, only
useLayoutEffect
is guaranteed to be ran once in the commit phase. See this video: youtube.com/watch?v=V1Ly-8Z1wQA at 16:05.If that's correct, then we could change it to something like:
And I think that would work together better with React's guarantees. What do you think?
Agree 👍
Also, if we assume this, what happens to time slicing?
This doesn't work guys. Have you tested it?