Relative Content

Tag Archive for next.jsreact-hooks

use a hook inside a function

I’m a beginner in react and JS. I want to refactor and clean up my endless files a little and seperating in files for different tasks.
So I created a lib folder and created a file called calculatePercentage.js and I want to use a useContext hook there. How is this possible to achieve? Do I need to create a component?

Cannot run function with useImperativeHandle

I am trying to use useImperativeHandle but still getting error “Cannot add property current, object is not extensible”. In every tutorial is code written in similar way and is working correctly. There is something that I am missing, but i dont know what.