DEV Community

Aditya Rawas
Aditya Rawas

Posted on • Edited on

What is React hooks ?

Hooks where added in React version 16.8 which allows you to use React without having to write a class.
Ex. State of a component.

In react version <16.8 you can only use states only within class components. With hooks you can use states in other react features without writing a class.

Keep in mind that hooks don't work inside classes

Hooks are the function that hooks into React state and lifecycle features from function components

Rules to use Hooks.

  • Can be called only on top level. Never call hooks inside any condition, loops if nested functions
  • Only use it in React functions Hooks can be called either from custom hooks of from React function components

Aditya Rawas Coffee

Top comments (0)

Jetbrains image

Is Your CI/CD Server a Prime Target for Attack?

57% of organizations have suffered from a security incident related to DevOps toolchain exposures. It makes sense—CI/CD servers have access to source code, a highly valuable asset. Is yours secure? Check out nine practical tips to protect your CI/CD.

Learn more

👋 Kindness is contagious

Value this insightful article and join the thriving DEV Community. Developers of every skill level are encouraged to contribute and expand our collective knowledge.

A simple “thank you” can uplift someone’s spirits. Leave your appreciation in the comments!

On DEV, exchanging expertise lightens our path and reinforces our bonds. Enjoyed the read? A quick note of thanks to the author means a lot.

Okay