Broadly speaking Effects let you specify side effects that are caused by rendering itself rather than by a particular event. They run at the end of a commit after the screen updates.
Keep in mind that Effects will run after *every* single render and commit. One thing we can do to make this more efficient is to use a dependency array so that React only calls the useEffect when the dependency changes.
[[useRef in React]] shouldn't go in the dependency of an effect since they are mutable without triggering a re-render and React won't know to re-run the effect.