Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React hooks not working #6

Open
rdourado-synd opened this issue Jul 5, 2024 · 1 comment
Open

React hooks not working #6

rdourado-synd opened this issue Jul 5, 2024 · 1 comment

Comments

@rdourado-synd
Copy link

I tried adding a simple useState hook in one of the components and it throws an error: Cannot read properties of null (reading 'useState'). Do you know how to fix this? Thank you!

@saiTharunDusa
Copy link

saiTharunDusa commented Jul 11, 2024

Hello @rdourado-synd, I think the following are the possible issues for the above error.

  1. Make sure to import the useState hook from react library as "import {useState} from 'react'; "
  2. Make sure to use it inside a functional component as
    const MyComponent = () => {

const [ temp, setTemp ] = useState('');

return (.......);

}

I hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants