How close should a hook be to its usage? episode artwork

EPISODE · Jan 12, 2023 · 3 MIN

How close should a hook be to its usage?

from The Call Kent Podcast · host Kent C. Dodds

Transcript: Key Kent! Big fan since I started learning React many moons ago! My name is Asier and I hope you're having a good day. My question is about React custom hooks and your opinion on the following. Imagine there is one parent component in charge of rendering two children components. This parent component is using a custom hook to retrieve some relevant data, let's say that it receives the user name and the date of birth for instance. The first child component requires a prop for the user name and another for the date of birth; and the second child requires another prop but only for the date of birth. My assumption was always to use the hook as close as possible to its usage, in this case, within both children components and not in the parent component. What should be the more readable choice between using the hook just once in the parent component and drilling the props downwards to the children, as opposed to using the hook in each individual hook?Thanks!How close should a hook be to its usage?

Episode metadata supplied by the publisher feed · Published Jan 12, 2023

Embed this episode

NOW PLAYING

How close should a hook be to its usage?

0:00 3:27

No transcript for this episode yet

We transcribe on demand. Request one and we'll notify you when it's ready — usually under 10 minutes.

No similar episodes found.

No similar podcasts found.

Frequently Asked Questions

How long is this episode of The Call Kent Podcast?

This episode is 3 minutes long.

When was this The Call Kent Podcast episode published?

This episode was published on January 12, 2023.

Can I download this The Call Kent Podcast episode?

Yes. Use the download control on the episode player to save the publisher-provided media file.
URL copied to clipboard!