DEV Community

loading...

Discussion on: The Definitive React Hooks Cheatsheet

Collapse
paramharrison profile image
Paramanantham Harrison

Thanks man. Are you sure about naming with ‘use’?
I don’t think it’s mandatory, you can create any named function as hooks. Probably this might be the recommended way same as how HOC are made with ‘with’ prefix

Collapse
claudiobernasconi profile image
Claudio Bernasconi

It's a suggestion by the React team - a best practice to make the intent clear.

Collapse
antjanus profile image
Antonin Januska Author

Interesting. I guess I haven't tested it but it's straight from their docs:

A custom Hook is a JavaScript function whose name starts with ”use” and that may call other Hooks

Collapse
camilomejia profile image
Camilo Mejía

The React team provide an ESLint plugin that prevents incorrect usage of hooks, but you must name them with use.

reactjs.org/docs/hooks-faq.html#wh...

Collapse
paramharrison profile image
Paramanantham Harrison

Yeah I got it, thanks for the link