Props vs State in React

Alice Richardson
2 min readApr 21, 2020

--

Normally you start out with React’s JSX syntax for rendering something to the browser when learning about React. Basically JSX (Html mixing JavaScript)

In a React component, props stand for properties and are being used for passing data from one component to another. State allows you to create components that are dynamic and interactive.

HOW TO PASS PROPS FROM CHILD TO PARENT COMPONENT?

There is no way to pass props from a child to a parent component.

When data is passed from a parent component to a child component this is called passing props. Props are read-only. There are many situations when writing React where you’ll want to pass a function as a prop to change the state of a parent component.

What is the state?

State is like a data store to the React component. It is mostly used to update the component when the user performs some action like clicking a button, typing some text, etc. State could only be used in class components, not in functional components before the introduction of hooks. After the initial state setup, the way you can update the state by using the method called setState( ).

Example of how to setState ( )

React is a Javascript library/frontend framework that allows developers to make complex applications faster and more organized with components. I hope this blog helps you understand the basics of props and state.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Alice Richardson
Alice Richardson

Written by Alice Richardson

Software Development with a background designer.

No responses yet

Write a response