Comments (10)
Hi @sboopal ,
Reason for you to getting the error.
React Hook Form using React Hook which required to have version 16.8.
"peerDependencies": {
"react": "^16.8.0",
"react-dom": "^16.8.0"
}
The benefit of React Hook is to let you use state and other React features without writing a class, but at the same time it won't work with Class component, hence React Hook Form will not work with Class component.
From React documentation:
You can’t use Hooks inside of a class component, but you can definitely mix classes and function components with Hooks in a single tree. Whether a component is a class or a function that uses Hooks is an implementation detail of that component. In the longer term, we expect Hooks to be the primary way people write React components.
you can refer examples to get a quick start: https://github.com/bluebill1049/react-hook-form/tree/master/examples
from react-hook-form.
hey @sboopal , how did you go with functional component instead of class component? let me know if you need some help.
from react-hook-form.
from react-hook-form.
here is a quick sandbox for validating couple selections. (functional component)
https://codesandbox.io/s/qk47j6854j
hope you find this useful
cheers
bill
from react-hook-form.
from react-hook-form.
Firstly, make sure you check your package.json
for React version, is it 16.8 above?
If so, then it is better to convert to functional component and try out react-hook-form
with the example I have supplied above.
If you want more examples, which can be found here:
https://github.com/bluebill1049/react-hook-form/tree/master/examples
API has been fully documented here too:
https://react-hook-form.now.sh/api
let me know if these are helpful.
cheers
bill
from react-hook-form.
Hey @sboopal, is there anything I can help more? otherwise, I may have to close this issue.
from react-hook-form.
from react-hook-form.
hope you get the chance to use react hook form in the future :)
from react-hook-form.
https://www.youtube.com/watch?v=UvH70UkbyfE&t=1275s
from react-hook-form.
Related Issues (20)
- issue: Exceptions happening in production: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
- issue: Form fields become unresponsive after multiple submissions with reset HOT 2
- issue: where are the messages for basic validation
- issue: zod / zodResolver / .refine()
- issue: Changing nested defaultValues before rendering Controller causes error: Cannot set properties of undefined (setting 'mount') HOT 1
- issue: useFormContexts error object empty desipite validation invalidating the form HOT 2
- issue: formState: { errors } and config: { errors } (infinite rerendering) HOT 3
- Values are out of sync when a field disabled attribute depends of another field value HOT 1
- issue: [DRAFT] using the new version of the library crashes the App component HOT 1
- v6 React Dependency Query HOT 2
- issue: formState: { errors } and config: { errors } (infinite rerendering) HOT 1
- issue: Dirty array fields get reset even though `keepDirtyFields: true` HOT 2
- issue: field named with dot like settings.default_port cause isValidating stuck to true HOT 1
- issue: form.reset(values) ignores undefined values HOT 2
- issue: when setting validation to min: 2 value 0 is ignored
- issue: bad setState() call inside `Controller` error when early returning and accessing `formState.isValid`
- issue: Problem with focus precedence HOT 2
- Registering nested objects changes default values
- issue: (in my project only) infinite rerender when using errors from formState and errors in hook configuration HOT 5
- issue: when use formState.isValid, fieldArray replace will make resolver call many times 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 react-hook-form.