Questions and answers
Here are some questions and answers to refresh your knowledge:
- What is a side effect?
A side effect is when a function relies on or modifies something outside of its input arguments. A very common side effect is the use of
console.log
inside a function. - What is
useEffect
?The
useEffect
hook is a way of defining a side effect callback to be invoked after a screen update in React. The effect can be invoked every time or when one of its dependencies changes. Therefore, theuseEffect
hook can be also used for listening for value changes. - What are the most common uses of
useEffect
?The
useEffect
hook is a common hook in the React family. If used along with theuseState
hook, it can easily communicate with external resources and bring results on screen. External resources can be web servers, DOM elements,window
objects,document
objects, or any third-party entities.