Hacker News new | past | comments | ask | show | jobs | submit login
Creating Custom Hooks in Reactjs (pieces.app)
1 point by piecesteam on Sept 19, 2022 | hide | past | favorite | 1 comment



Hooks are wrappers that help to encapsulate repeated stateful logic so that it can be used and shared later across multiple components. A hook is a feature that allows you to use all class-based components’ life cycle methods in functional-based. components. To create your own custom hook, React tells us to follow certain guidelines. Hooks should be called at the top of the component. We should avoid using hooks inside a condition or a loop because React will be uncertain about the order of execution of the hooks.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: