Share Logic Across Multiple React Components with Custom Hooks

InstructorKent C. Dodds

Share this video with your friends

Send Tweet

In React 16.6, there are hooks that allow you to use state in functions components in a simple way.

With these hooks, you can share the logic easily. In this lesson, we'll break out the setCount hook into it's own function and use it in a Component.

Jikku Jose
~ 6 years ago

My two cents: Think it might be better to use the returned function from the custom hook to "set" the state rather than a function to directly update the state. That way it will be consistent to other hook methods.