receter / my-component-library

101 stars 26 forks source link

React hooks not working #6

Open rdourado-synd opened 4 months ago

rdourado-synd commented 4 months ago

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 commented 4 months ago

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.