AI Hints
Home›React Tutorial›Interview Prep and Final Quiz
React · Lesson 116 of 120

More Interview Questions

Part two.

⏱ 2 min read▶ Video at 1:36:00🎓 Free
Watch this lesson in the React courseWatch on YouTube ↗Full React course

Here are a few more questions that come up often, mostly about hooks and effects.

  • More questions
  • Hooks
  • Effects

Explain useEffect

Use effect runs code after rendering, to sync with things outside React. The dependency array decides when it runs again. And the cleanup function undoes it, before the next run or when the component goes away.

keyvalue
Runsafter render
Depswhen to re-run
Cleanupundo it
Foroutside React

Controlled versus uncontrolled

A controlled input gets its value from state, and updates it on every change. An uncontrolled input keeps its own value, and you read it when needed, from a ref or form data.

keyvalue
Controlledvalue from state
UncontrolledDOM keeps it
Read withref or FormData
Commoncontrolled

Why are hooks rules strict?

React stores each hook's data by its position in the call order. If a hook is skipped on one render, every hook after it gets the wrong data. So hooks must run in the same order, every time.

keyvalue
Stored bycall order
Skip onedata shifts
Sotop level only
Checked bythe linter

Summary

Effects, controlled inputs, and the rules of hooks round out the essentials. Next, the final quiz.

Key takeaways
  • useEffect
  • Controlled
  • Hook order
Next up: Final Quiz — test yourself