React Props and Sate

Damany Bailey
1 min readJun 9, 2021

In react, components are responsible for generating HTML. To make HTML generate dynamically we need to pass data to our component so that our component can use variables and serve dynamic HTML. There are two types of data in react state (private data available in component only) props (public data can be passed to component from outside)

What are props in React?

Props are basically data that flows from one to another component as a parameter. Props can not be modified in a component. React Props are like function arguments in JavaScript and attributes in HTML. The component uses this data to generate dynamic HTML elements. Props are passed to components via HTML attributes.

What is the state in react?

React components has a built-in state object which is private to a component. State can not be accessed from outside of the class. However, it can be passed as an argument to another component. Whenever the state is changed component calls the render function to render HTML elements.

--

--