Lädt...


🔧 Are you using the custom hooks in React right?


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Custom hooks are method that helps us to create and maintain functionalities outside the component that can be re-used and called across various components in the application.
Does it sound familiar? Yes, they are basically util functions that we tend to keep in utils.js when we were working before the hooks storm or before even started using libraries like React or Angular.

Also, this is a proper example for Dependancy Inversion in S.O.L.I.D principles.

Here instead of keeping them as functions in a js file, we are keeping them as hooks that can be called at the top of the component.

Why use custom hook?

As the application grows in size, it is important to abstract the logic outside the component that can be re-used. It helps us to improve modularity of the code. By moving such logics outside, you can keep many Components simply as presentational components.

By creating your own custom hook, you refrain from using an external library to add new functionality thus saving space and maintenance cost.

As custom hooks are meant to be used on top of the component like in-built hooks, you can use useState, useEffect or even custom hooks inside the same.

Points to remember while creating a hook

  • Start with “use” keyword.
  • Keep SOLID principle in the mind — The hook should do only one thing.
  • Define the types before hand for params — If typescript — great.
  • Should be used only at the top of the component where you are consuming
  • Do not add new params or options thinking it might come in the future. Keep room for scaling; when there is a need, we can extend the hook’s capability

For the complete article, please visit medium blog.

...

🔧 Are you using the custom hooks in React right?


📈 41.05 Punkte
🔧 Programmierung

🔧 Deep Dive into React 🚀🚀Hooks: useState, useEffect, and Custom Hooks 🔍


📈 39.91 Punkte
🔧 Programmierung

🔧 Deep Dive into React Hooks: useState, useEffect, and Custom Hooks


📈 39.91 Punkte
🔧 Programmierung

🔧 Bloodline of Hooks: Custom Hooks in React for Advanced Devs


📈 39.91 Punkte
🔧 Programmierung

🔧 React Hooks - Top7 Most Commonly Used React Hooks for Efficient Component Management


📈 38.38 Punkte
🔧 Programmierung

🔧 🪝Mastering React Hooks Transform Your React Development with Hooks🚀


📈 38.38 Punkte
🔧 Programmierung

🔧 Có thể bạn chưa biết (Phần 1)


📈 34.69 Punkte
🔧 Programmierung

🔧 Tìm Hiểu Về RAG: Công Nghệ Đột Phá Đang "Làm Mưa Làm Gió" Trong Thế Giới Chatbot


📈 34.69 Punkte
🔧 Programmierung

🔧 Learn React Hooks – Common Hooks Explained with Code Examples


📈 32.39 Punkte
🔧 Programmierung

🔧 scriptkavi/hooks: Customizable and Open Source React Hooks


📈 32.39 Punkte
🔧 Programmierung

🔧 React Hooks – How to Use the useState & useEffect Hooks in Your Project


📈 32.39 Punkte
🔧 Programmierung

🔧 React Hooks – How to Use the useState & useEffect Hooks in Your Project


📈 32.39 Punkte
🔧 Programmierung

🔧 Using Custom React hooks in NextJS?


📈 30.77 Punkte
🔧 Programmierung

🔧 Using Custom Hooks in multiple React Components.


📈 30.77 Punkte
🔧 Programmierung

🔧 Flutter Hooks Tutorial: Flutter Animation Using Hooks (useEffect and useAnimationController)


📈 30.47 Punkte
🔧 Programmierung

🔧 15 Useful React Custom Hooks That You Can Use In Any Project


📈 30.02 Punkte
🔧 Programmierung

🔧 Using React Hooks in React Native: Best Practices


📈 29.25 Punkte
🔧 Programmierung

🔧 Save Hours of Coding: Build Powerful Custom Hooks in React


📈 26.7 Punkte
🔧 Programmierung

🔧 Creating Custom Hooks in React: Enhancing Component Reusability with Audio Playback


📈 26.7 Punkte
🔧 Programmierung

🔧 Mastering Custom Hooks in React: A Comprehensive Guide


📈 26.7 Punkte
🔧 Programmierung

🔧 Beyond useEffect: Simplifying React with Custom Hooks


📈 26.7 Punkte
🔧 Programmierung

🔧 A Beginner's Guide to React Custom Hooks


📈 26.7 Punkte
🔧 Programmierung

🔧 Building Custom Hooks in React: Best Practices and Use Cases


📈 26.7 Punkte
🔧 Programmierung

🔧 Custom Hooks in React


📈 26.7 Punkte
🔧 Programmierung

🔧 Creating Custom Hooks in React and TypeScript


📈 26.7 Punkte
🔧 Programmierung

🔧 Building Powerful Components with React Custom Hooks


📈 26.7 Punkte
🔧 Programmierung

🔧 Implementing Dark Mode with React, Jotai, and Custom Hooks


📈 26.7 Punkte
🔧 Programmierung

🔧 Writing Custom React Hooks with Typescript


📈 26.7 Punkte
🔧 Programmierung

🔧 Supercharging React Components with Custom Hooks


📈 26.7 Punkte
🔧 Programmierung

🔧 Best Tips for Creating Custom Hooks in React


📈 26.7 Punkte
🔧 Programmierung

🔧 Top 10 Most Useful Custom Hooks in React


📈 26.7 Punkte
🔧 Programmierung

🔧 React Custom Hooks (useEventListener)


📈 26.7 Punkte
🔧 Programmierung

🔧 Creating Custom Hooks in React


📈 26.7 Punkte
🔧 Programmierung

🔧 React Custom Hooks (useRefs)


📈 26.7 Punkte
🔧 Programmierung

🔧 Reusing Logic in React with Custom Hooks: a Practical guide


📈 26.7 Punkte
🔧 Programmierung

matomo