Y
Y
yumakaev2020-01-09 22:13:53
React
yumakaev, 2020-01-09 22:13:53

How to call a custom hook in a hook?

Good evening!
Why can't I call a custom hook in the useEffect hook ?
https://codesandbox.io/s/frosty-pine-yjv6y

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolay Matyushkin, 2020-01-10
@Devilz_1

Isn't the error text enough for you?))
Invalid hook call. Hooks can only be called inside of the body of a function component.
Invalid hook call. Hooks can only be called inside the body of a functional component.
Well, the codepen itself swears, stating it quite clearly.
React Hook "useCustom" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function.
I didn’t quite understand the purpose of this action, but here is a clear example of using a custom hook.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question