What is the difference between state and props?

Technology CommunityCategory: ReactWhat is the difference between state and props?
VietMX Staff asked 3 years ago

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. They are received from above 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.