Member-only story

ReactJS Interview Prep: components, state, props, hooks and JSX

Marika Lam
1 min readJun 18, 2024

--

What is a component?

  • component is a reusable piece of code that can use elements on a page.
  • components can be classes or functions
  • allows us to breaks down complex UIs
  • components can get props passed in a hold state

What is a state?

  • allows components to store their own data
  • its typically used to store data that will change
  • can define a state in a functional component by using useState hook
  • there is global state, which relates to the app as a whole and not just a single component

What is props?

  • props are arguments passed into React components. they are passed to components via HTML attributes
  • props are also how you pass data from one component to another, as parameters
  • props are like function arguments in javascript and attributes in HTML
  • props are read-only

What is hooks?

  • react used to use only class components with lifecycle methods, but now there is a new concept called hooks for functional components
  • allows us to use state and other react features within functional components
  • the 2 main hooks that are used are useState and useEffect
  • you can also create your own custom hooks

What is JSX?

  • the output of a component is JSX
  • it stands for javascript syntax extension
  • it is a HTML like syntax within Javascript
  • it’s great because it’s dynamic. it’s what HTML will be if it was a programming language
  • you can have loops, conditionals, expressions

--

--

No responses yet