You must Sign In to post a response.
  • Category: WinRT/Metro App Development

    Custom Hooks In React

    Building custom hooks in React is always a good idea if it helps you avoid repeating code!

    Custom hooks make life easier for us when we have to build the functionality that can be stored inside a utility, spending time to come up with a great hook will save you lots of time in the future!
  • #26404
    Custom Hooks are a mechanism to reuse stateful logic (such as setting up a subscription and remembering the current value), but every time you use a custom Hook, all states and effects inside of it are fully isolated.

    Reason for using Custom Hook: The main reason to write a custom hook is for code reusability. For example, instead of writing the same code across multiple components that use the same common stateful logic (say a "setState" or localStorage logic), you can put that code inside a custom hook and reuse it.

  • Sign In to post your comments