Giter VIP home page Giter VIP logo

Comments (2)

gertdreyer avatar gertdreyer commented on May 26, 2024

Strict Mode is a Breaking Change in React 18...
It emulates unmounting and remounting the fields which would then obviously clear all the values from the formState.

There are workarounds out there e.g. https://blog.ag-grid.com/avoiding-react-18-double-mount/

Willing to accept a PR that fixes this behaviour.

from react-final-form.

Axnyff avatar Axnyff commented on May 26, 2024

Hi!
I recently did a project on which we relied a lot on destroyOnUnregister and I'd be hard to implement the same feature with a FormSpy so I looked into your suggestion.

It's a bit complicated to try and handle correctly the behavior when you have dependencies or changing effect function ( the code in the link broke quite a lot of tests in final-form

I've managed to have a version that works here ( and for which the tests passes on react-final-form )
https://github.com/Axnyff/useEffectOnceInStrictMode/blob/main/useEffectOnceInStrictMode.ts
with some tests here
https://github.com/Axnyff/useEffectOnceInStrictMode/blob/main/useEffectOnceInStrictMode.test.js

I'm not sure I'm not missing some weird edge cases that would break the regular behavior of useEffect.
It seems to fix the behavior of destroyOnUnregister if I only fix that useEffect: https://github.com/final-form/react-final-form/blob/main/src/useField.js#L113

It looks like it would be hard to bring the tests in react-final-form as they are only valid for react 18.
Do you think there's a way I can do a PR to fix that behavior ?

from react-final-form.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.