So how can i write those functions on a separate js file and import them on the component that calls them ?
The solution is just as you said here, wirte the function in a separate file and import it in the two component you want to use it and then use it. And you do it like any other function, just use import/export keyword.
Or you can go even one step further and make it a custom hook
Thanks fro the reply.. I think useContext will be a solution here. In this case, i want the functions to fetch some api and call them on a onClick att inside a input..
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The solution is just as you said here, wirte the function in a separate file and import it in the two component you want to use it and then use it. And you do it like any other function, just use import/export keyword.
Or you can go even one step further and make it a custom hook
Thanks fro the reply.. I think useContext will be a solution here. In this case, i want the functions to fetch some api and call them on a onClick att inside a input..