Giter Site home page Giter Site logo

Doesn't unregister fields about input HOT 18 CLOSED

GProst avatar GProst commented on August 18, 2024
Doesn't unregister fields

from input.

Comments (18)

bluebill1049 avatar bluebill1049 commented on August 18, 2024 1

sorry i know why now!

from input.

bluebill1049 avatar bluebill1049 commented on August 18, 2024 1

I will test more on this feature today and get a proper fix. Idea is you don’t need to pass unregistef let register return it

from input.

GProst avatar GProst commented on August 18, 2024

@bluebill1049 I'm afraid this didn't fix it =(
Unfortunately, having problem of updating react-hook-form version in the Sandbox above but locally in my project it still doesn't unregister fields for me... Double-checked that version is 3.28.5, removed/installed node_modules from scratch just in case - didn't help

from input.

bluebill1049 avatar bluebill1049 commented on August 18, 2024

oh really? what's register return?

from input.

bluebill1049 avatar bluebill1049 commented on August 18, 2024

still return undefined?

from input.

GProst avatar GProst commented on August 18, 2024

@bluebill1049

ƒ () {
    return unregister(name);
}

but the fields are still passed to the onSubmit handler...

from input.

bluebill1049 avatar bluebill1049 commented on August 18, 2024
    if (validationOptions && isString(validationOptions.name)) {
      registerIntoFieldsRef(
        { name: validationOptions.name },
        validationOptions,
      );
      return () => unregister(name);
    }

from input.

bluebill1049 avatar bluebill1049 commented on August 18, 2024

code i have in RHF

from input.

GProst avatar GProst commented on August 18, 2024

@bluebill1049 no worries!

from input.

bluebill1049 avatar bluebill1049 commented on August 18, 2024

try this beta: [email protected]
i will do proper fix today

from input.

GProst avatar GProst commented on August 18, 2024

@bluebill1049 I'm not sure why but some of my inputs stopped updating values at all, like I'm typing and nothings fills. I see that handleChange method is invoked, name seems to be correct and data too but the value is undefined anyway during the next render.
Interestingly that this happens to some fields, not sure I understand how they are different...

[email protected]

I was talking about handleChange in RHFInput

from input.

GProst avatar GProst commented on August 18, 2024

Perhaps this is something on my side, trying to debug, but all I did was updating a lib

from input.

GProst avatar GProst commented on August 18, 2024

Reverted to 3.28.5 and fields started to work again.

@bluebill1049 I found why some fields work okay and some don't work.
Fields work normally if they don't have default values provided to useForm (3.28.6-beta.1)

from input.

bluebill1049 avatar bluebill1049 commented on August 18, 2024

looks like this version works: https://codesandbox.io/s/react-hook-form-field-array-advanced-with-delete-insert-append-edit-l19pz

from input.

GProst avatar GProst commented on August 18, 2024

@bluebill1049
If you set some default values to useForm you won't be able to update a field:
https://codesandbox.io/s/react-hook-form-field-array-advanced-with-delete-insert-append-edit-oh0jl

from input.

bluebill1049 avatar bluebill1049 commented on August 18, 2024

ok i see

from input.

bluebill1049 avatar bluebill1049 commented on August 18, 2024

working one: https://codesandbox.io/s/react-hook-form-field-array-advanced-with-delete-insert-append-edit-to-delete-elloq
i will have publish both libs :)

from input.

bluebill1049 avatar bluebill1049 commented on August 18, 2024

https://codesandbox.io/s/react-hook-form-field-array-advanced-with-delete-insert-append-edit-l19pz works now going to publish both FYI

from input.

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.