Question · Vibe coding with Claude Code course · Module 10: TikTok clone

Braces in the ref function

Why did Claude write ref={(el) => { videoRefs.current[i] = el; }} with curly braces?

Answer options

  • Without braces React would call the ref function twice
  • In React 19 a ref function may return only nothing or a cleanup function, and the version without braces returns the assigned value and fails tsc
  • Without braces the video element would not land in the array
  • ESLint requires braces in every arrow function

You can check the correct answer by solving this task in the CodeWorlds game.