Interview Q&A / React

INTERVIEW Q&A · 58 QUESTIONS

React interview questions

Rendering, state, hooks, keys and effects, explained with small examples.

  1. How do you give a prop a default value in a modern function component?

    Use default values in the destructured parameters, such as function Badge({ color = 'blue' }). The default applies only when the prop is undefined, not when it is null or an empty string.

    BeginnerQuick answer1 min read