in React JS by
Q:

What is the difference between state and props?

1 Answer

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.

Props and State do similar things but are used in different ways. The majority of our components will probably be stateless. Props are used to pass data from parent to child or by the component itself. They are immutable and thus will not be changed. State is used for mutable data, or data that will change. This is particularly useful for user input.

Click here to read more about React JS
Click here to read more about Insurance

Related questions

0 votes
asked Feb 23 in React JS by SakshiSharma
0 votes
asked Jul 2, 2019 in React JS by Venkatshastri
0 votes
asked Jul 2, 2019 in React JS by Venkatshastri
0 votes
asked Dec 8, 2020 in React JS by SakshiSharma
0 votes
asked Jun 19, 2020 in React JS by JackTerrance
...