1.

What are props in React?

Answer»

The props in React are the inputs to a component of React. They can be single-valued or objects having a set of values that will be passed to components of React during creation by USING a naming convention that almost LOOKS similar to HTML-tag attributes. We can say that props are the data passed from a parent component into a child component.

The main purpose of props is to provide different component functionalities such as:

  • Passing custom data to the React component.
  • Using through this.props.reactProp inside render() method of the component.
  • Triggering STATE changes.

For example, consider we are creating an element with reactProp property as given below: <Element reactProp = "1" />
This reactProp name will be considered as a property attached to the native props object of React which already EXISTS on each component created with the help of React library: props.reactProp;.



Discussion

No Comment Found