Member-only story

Top 5 Basic React JS Interview Questions and Answers

Marika Lam
2 min readSep 20, 2020

--

  1. What is a state?
  • It is an object that holds some information that may change over the lifetime of the component
  • Try to make the state as simple as possible and minimize the number of stateful components
  • state is similar to props, except it is private and fully controlled by the component
  • state is not accessible to any component other than the one that owns and sets it

2. What are props?

  • props are inputs to components
  • They are single values or objects containing a set of values that are passed to components on creation
  • They are data passed down from a parent component to a child component

3. What is the difference between state and props?

  • Both props and state are plain Javascript objects
  • Both hold information that influences the output of render
  • Difference: props get passed to the component, state is managed within the component

4. What is Virtual DOM?

  • It is an in-memory representation of a Real DOM
  • It is kept in memory and synced with the “real” DOM
  • It’s a step that happens between the render function being called and the displaying of elements on the screen
  • The entire process is called reconciliation

--

--

No responses yet