Create a Custom Hook in React by Wrapping useState

Chris Achard
InstructorChris Achard
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 4 years ago

Custom hooks in React are functions, and we can write them by combining other, preexisting hooks.

In this lesson, we'll wrap the useState React hook to create a hook that automatically pulls out the event.target.value of an input's onChange callback. We'll then use that hook directly as the onChange prop of a text input.