my-component-library
my-component-library copied to clipboard
React hooks not working
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!
Hello @rdourado-synd, I think the following are the possible issues for the above error.
- Make sure to import the useState hook from react library as "import {useState} from 'react'; "
- Make sure to use it inside a functional component as const MyComponent = () => {
const [ temp, setTemp ] = useState('');
return (.......);
}
I hope that helps.