Comments (11)
hey @kotarella1110 think it's better to useCallback
at app level, then user will be in control if external dependency changed.
from documentation.
This is not a bug and intended behavior.
Feel free to improve.
from documentation.
Sure, but in my case, I'm doing validation based on a dynamic validation schema, (the schema is a prop). I can force re-mount the whole component whenever the schema changes, sure, but confirming this either as a bug or as intended would help a lot of people if pointed out in docs.
Perhaps validation context can work in those cases, and again it should be pointed out in docs.
validationContext
can't work in those cases.
We need to leave the validationContext
outside of the component, just like the validationResolver
function.
already fixed react-hook-form/react-hook-form@c00722b
from documentation.
Try this: https://codesandbox.io/s/agitated-fire-w9myu
from documentation.
@bluebill1049 Should validationResolver
be memoized at app-level?
Why aren't you using the useCallback
inside the useForm
method to memoize the validationResolver
?
from documentation.
Lovely, I’ll submit a PR for the docs.
from documentation.
Awesome thanks.
from documentation.
@bluebill1049 On the other hand, when using useCallback
with a dependency, useForm
exhibits the same behaviour as the one reported here, whenever the reference for validationResolver
changes.
I assume when that does happen, registered field elements become unregistered. And because those fields are not remounted, they won't trigger register again. Am I correct?
So until that is changed/fixed, I shouldn't suggest using callbacks that rely on the component state in the docs.
from documentation.
It's almost easier and better to leave resolver
function outside the component.
https://react-hook-form.com/api/#validationResolver
from documentation.
Sure, but in my case, I'm doing validation based on a dynamic validation schema, (the schema is a prop). I can force re-mount the whole component whenever the schema changes, sure, but confirming this either as a bug or as intended would help a lot of people if pointed out in docs.
Perhaps validation context can work in those cases, and again it should be pointed out in docs.
from documentation.
moving it under website to improve the doc
from documentation.
Related Issues (20)
- Typo: "recommend" instead of "recommended"
- issue: Application error: a client-side exception has occurred (see the browser console for more information).
- Improve documentation for useWatch exact
- Update twitter icon HOT 2
- issue: useFieldArray Unable to track newly added elements When "shouldUnregister" is enabled HOT 1
- The `RegisterOptions` type does not match the documentation
- Document watch callback type parameter
- issue: In the specified sandbox environment, when the onChange event handler is invoked with undefined as its argument, the Component does not receive the updated value. However, despite this, the form data is successfully updated. HOT 4
- issue: maxLength does not limit input field to length HOT 1
- Two different documentation versions
- issue: Website appears as a blank background HOT 2
- Documentation: keepIsSubmitSuccessful missing from documentation
- 🥇 Features : Scrollspy or scrolling navigation on documentation site HOT 2
- Feature Request: Implement Scrollspy for Dynamic Navigation
- issue: typo/grammar-issues in /docs/useform/seterror HOT 2
- form builder: "input creator" form state not updated correctly when switching between inputs
- Beekai.com outbound connection on homepage? HOT 1
- Improve documentation on setError HOT 1
- Invalid dependency tree from npm's pov HOT 1
- Typo HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from documentation.