reactjs_interview_q&a
June 21, 2020

How to create components in React?

There are two possible ways to create a component.

  1. Function Components: This is the simplest way to create a component. Those are pure JavaScript functions that accept props object as first parameter and return React elements:

2. Class Components: You can also use ES6 class to define a component. The above function component can be written as: