Skip to content
Advertisement

I am using UseEffect Hook, but still component is getting Uncaught TypeError: Cannot set properties of null. in react

I have to give a hover effect to a certain element that has an id “address-instructions”. I have used UseEffect so that it is only accessed after being rendered, but I still get Uncaught TypeError: Cannot set properties of null (setting ‘onmouseover’) , which indicates that the component is not rendering. Please help. Thank you in advance.

JavaScript

Advertisement

Answer

you can use useRef for the same…

JavaScript

You can use above code directly on codesandbox.

I hope this will help you! Happy coding…

Advertisement