Skip to content
This repository has been archived by the owner on Jun 2, 2023. 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
Labels
audio-answer Answers provided as an audio clip

Comments

@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 kentcdodds added the audio-answer Answers provided as an audio clip label Mar 20, 2019
@kentcdodds
Copy link
Owner

Hi @tuucan!

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
audio-answer Answers provided as an audio clip
Projects
None yet
Development

No branches or pull requests

2 participants