0 votes
in ReactJS by
What is the difference between state and props?

2 Answers

0 votes
by

The state is a data structure that starts with a default value when a

Component mounts. It may be mutated across time, mostly as a result of

user events.

Props (short for properties) are a Component’s configuration. Props are how

components talk to each other. They are received from above component

and immutable as far as the Component receiving them is concerned. A

Component cannot change its props, but it is responsible for putting together

the props of its child Components. Props do not have to just be data —

callback functions may be passed in as props.

0 votes
by

Both props and state are plain JavaScript objects. While both of them hold information that influences the output of render, they are different in their functionality with respect to component. Props get passed to the component similar to function parameters whereas state is managed within the component similar to variables declared within a function.

Related questions

0 votes
asked Jul 2, 2019 in ReactJS by Venkatshastri
0 votes
asked Jul 2, 2019 in ReactJS by Venkatshastri
...