useEffect hooks to run on every render of the component

useeffect without dependency array will run on every render / re-render. So whenever the component renders, the useEffect will also run.

This is useful when you have a use case to run a piece of code on each render.

But use it with caution, if you change any state inside those blocks. Your page will render indefinitely and cause a memory leak. It eventually seizes your browser tab.

useEffect(() => {
  console.log('this useEffect will run on every render');
});