React Hooks

The actual content comes from Kent C. Dodds.’s Epic React Course.

useState

useState returns a pair of values.

The first of the pair is the state value and the second is a function we can call to update the state.

What is State?

Lazy State Initialization

useEffect

It accepts a callback function which React will call after browser painting.

But there are various reasons a component can be re-rendered like when a parent component in the application tree gets re-rendered.

So we need a way to prevent side effects run frequently.

Dependency Array

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store