Giter Club home page Giter Club logo

Comments (10)

bluebill1049 avatar bluebill1049 commented on May 13, 2024

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.

bluebill1049 avatar bluebill1049 commented on May 13, 2024

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.

sboopal avatar sboopal commented on May 13, 2024

from react-hook-form.

bluebill1049 avatar bluebill1049 commented on May 13, 2024

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.

sboopal avatar sboopal commented on May 13, 2024

from react-hook-form.

bluebill1049 avatar bluebill1049 commented on May 13, 2024

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.

bluebill1049 avatar bluebill1049 commented on May 13, 2024

Hey @sboopal, is there anything I can help more? otherwise, I may have to close this issue.

from react-hook-form.

sboopal avatar sboopal commented on May 13, 2024

from react-hook-form.

bluebill1049 avatar bluebill1049 commented on May 13, 2024

hope you get the chance to use react hook form in the future :)

from react-hook-form.

samantaavijit avatar samantaavijit commented on May 13, 2024

https://www.youtube.com/watch?v=UvH70UkbyfE&t=1275s

from react-hook-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.