mthanh2209 / react-training

https://react-training-eight.vercel.app
0 stars 0 forks source link

Implement Reusing Logic with Custom Hooks #162 #186

Closed mthanh2209 closed 8 months ago

mthanh2209 commented 8 months ago
  1. What custom Hooks are, and how to write your own
    • Custom Hooks are JavaScript functions that allow you to reuse stateful logic across different React components.
    • To create a custom hook, you simply write a JavaScript function prefixed with the word "use". Inside this function, you can use built-in hooks or other custom hooks
  2. How to name and structure your custom Hooks
    • Name custom hooks with a "use" prefix
    • Structure custom hooks just like regular functions. They can take parameters and return values, similar to regular React hooks.
  3. When and why to extract custom Hooks
    • Extract custom hooks when you find yourself duplicating logic across multiple components.
    • It promotes reusability and maintainability, making it easier to manage and update shared logic.
    • Custom hooks can encapsulate complex logic, making the components cleaner and more focused.
vercel[bot] commented 8 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-training ❌ Failed (Inspect) Jan 29, 2024 8:03am
storybook ❌ Failed (Inspect) Jan 29, 2024 8:03am