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: register/unregister should affect isDirty in formState
- How to specify the default value type as the object
- issue: form.reset will cause useFieldArray to trigger watch subscription
- issue: radio buttons are not checked when "disabled" property is set HOT 5
- Method to update custom context after the form initialisation?
- issue: getFieldState from useFormContext does not have latest error state without referencing formState also
- issue: error object from both formState and fieldState are always undefined with useController HOT 1
- issue: Password match validation don't hide error, when input not mentioned in refine() 'path' has changed to valid
- issue: useFieldArray and getFieldState causes react console warnings HOT 4
- Form reset, append adds ghost empty fields HOT 5
- Allow JSX elements/React components to be returned as an error message HOT 3
- issue: setError does not work with ErrorMessage component
- issue: the `formState.errors`default type is incorrect HOT 1
- issue: disabled property in useForm applied to Form Provider does not apply to all radio inputs HOT 1
- issue: valueAsDate parses based on current timezone HOT 1
- issue: Duplicated checkboxes create the same values in array HOT 5
- issue: TypeScript error when specifying `defaultValues` with generic types in `useForm` HOT 1
- issue: When using reValidateMode: 'onBlur', the form doesn't submit when its single error is fixed HOT 6
- issue: Select input doesnt work when there's "," and "." HOT 1
- issue: Multi-page form validation issue with react-hook-form and arrays
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.