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
I just migrated from using the standard CRA installation to now using React + Next.js. Unsure if the following is a bug with Next.js (14.1.4) or uniforms (4.0.0-alpha.5)
After migrating, all uniforms AutoForms I implemented would now not have the AutoField state updated, even though they were previously working.
I implemented a very straightforward AutoForm per the docs just to see if it was an issue with my custom implementation, but that too failed.
After a bit of digging, the componentWillUnmount was causing the setState to be set to () => {}, despite the component being mounted subsequently.
I removed the this.setState = () => { }; line and was able to verify this now works as expected and the field state is being updated.
componentWillUnmount(){this.mounted=false;if(this.delayId){clearTimeout(this.delayId);}// There are at least 4 places where we'd need to check, whether or not we// actually perform `setState` after the component gets unmounted. Instead,// we override it to hide the React warning. Also because React no longer// will raise it in the newer versions.// https://github.com/facebook/react/pull/22114// https://github.com/vazco/uniforms/issues/1152this.setState=()=>{};}
I suspect this must be with the way Next.js deals with state and mounting of components. However, I can't find anything to suggest it's the Next.js installation that's causing the issue (not directly at least).
The text was updated successfully, but these errors were encountered:
Hi @cohenrobinson,
there is a similar issue #1194 (comment).
Could you have a look at it and tell me if it helps in any way?
Try disabling strict mode.
Hello!
I just migrated from using the standard CRA installation to now using React + Next.js. Unsure if the following is a bug with Next.js (14.1.4) or uniforms (4.0.0-alpha.5)
After migrating, all uniforms AutoForms I implemented would now not have the AutoField state updated, even though they were previously working.
I implemented a very straightforward AutoForm per the docs just to see if it was an issue with my custom implementation, but that too failed.
After a bit of digging, the componentWillUnmount was causing the setState to be set to () => {}, despite the component being mounted subsequently.
I removed the
this.setState = () => { };
line and was able to verify this now works as expected and the field state is being updated.I suspect this must be with the way Next.js deals with state and mounting of components. However, I can't find anything to suggest it's the Next.js installation that's causing the issue (not directly at least).
The text was updated successfully, but these errors were encountered: