UseEffect: it is used to perform the side effects for a functional component

Requ: to open certain components that time we can fetch something from the server and display it on the web.

Use Cases:

1).UseEffect function is executed at the time of mounting (calling a component)

2). Every time the UseEffect hook is called at the time of rerendering the component

I.e: if the component contains state, if changing state, everything that time re-render the component, if it is re-rendering then UseEffect function is executed.

Syntax : UseEffect ()

Explanation: it accepts two parameters

3). if you pass empty dependence, it is executed at the time of mounting only, otherwise, it will not executed.

UseEffect execution flow -

4). UseEffect execution through dependencies, if the state is changed then the useEffect function is executed otherwise useEffect function is not executed.

Cases :

1). First generate the UI after that the useEffect hook will be called.

2). If the state is changing then the entire component will be re-render (mounting).