Skip to content
This repository has been archived by the owner. It is now read-only.

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

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

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

tuucan opened this issue Feb 20, 2019 · 1 comment

Comments

@tuucan
Copy link

@tuucan 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
Copy link
Owner

@kentcdodds 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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants