Course lesson

Share Complex Logic across React Components with Custom Hooks

A lot of the time, when you define logic in a component, you will want to reuse it in a few different places within your application as separate instances.

Duration
3 min
Access
Free
Transcript
Available

A lot of the time, when you define logic in a component, you will want to reuse it in a few different places within your application as separate instances.

In this lesson, we will break out the logic of our StopWatch Component and use two instances within our stopwatch and compare the difference between the two lapse instances.

You'll learn:

  • Create a function as a custom hook for your components
  • Create multiple instances of the logic within a component
  • Compare the values between the two instances.