0

I was learning hooks in React and came across custom hooks and when how should be used. According to react docs "You can also create your own Hooks to reuse stateful behavior between different components". The question is should the custom hooks contain only stateful behavior, that is, use hooks like useState or useReducer that contain state or should custom hook contain any of provided hooks like useMemo or useCallback in order to be considered as custom hook. I just want to understand what is the right way to use custom hooks.

Mir
  • 11
  • 3
  • It explained in the docs, https://reactjs.org/docs/hooks-custom.html#useyourimagination, also mentioned on the same page what custom hook is: "A custom Hook is a JavaScript function whose name starts with ”use” and that may call other Hooks" so hooks don't have to be stateful. – Dennis Vash Mar 10 '21 at 18:35
  • Thanks for correcting, check related question here: https://stackoverflow.com/questions/66151248/do-react-hooks-really-have-to-start-with-use/66151737#66151737 – Dennis Vash Mar 10 '21 at 18:44

0 Answers0