Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it wrong to use custom hooks inside other custom hooks? #606

Closed
tuucan opened this Issue Feb 20, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@tuucan
Copy link

tuucan commented Feb 20, 2019

Well hooks make it possible for us to share logic across multiple components.

But you know... They are also functions...

Sometimes it is appealing to further break the logic that can be shared across multiple "hooks".

For a simple example; instead of using useContext inside a custom hook, i might want to useRequiredContext, which throws an error if the context is not available. Do I have to duplicate the logic of useRequiredContext to all of my custom hooks that uses it or can I just call that hook?

Thanks!

@kentcdodds

This comment has been minimized.

Copy link
Owner

kentcdodds commented Mar 20, 2019

Hi @tuucan!

Great question. Here's your answer: https://www.briefs.fm/3-minutes-with-kent/99

@kentcdodds kentcdodds closed this Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.