You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Actually there is single place in docs which allows to do side effect (change state) during render if it is wrapped inside certain condition,
however, even there they warn against DOM manipulation:
A condition like items !== prevItems is necessary to avoid loops. You may adjust state like this, but any other side effects (like changing the DOM or setting timeouts) should stay in event handlers or Effects to keep components pure.
Summary
React docs warn us to not perform side effects during render (or even inside the body of hook like
useMemo
).However, here: https://react.dev/reference/react-dom/hooks/useFormStatus#read-form-data-being-submitted,
it seems that is what is happening:
submittedUsername.current = data?.get('username');
Isn't writing to ref a side effect?
Actually there is single place in docs which allows to do side effect (change state) during render if it is wrapped inside certain condition,
however, even there they warn against DOM manipulation:
Page
https://react.dev/reference/react-dom/hooks/useFormStatus#read-form-data-being-submitted
Details
No response
The text was updated successfully, but these errors were encountered: