DEV Community

Cover image for PROPS AND STATES EXPLAINED
OCHADE EMMANUEL
OCHADE EMMANUEL

Posted on

PROPS AND STATES EXPLAINED

What is the Difference Between Props and States
In React, states and props are data, but they differ by one key concept, that is their origin.
Basically, when a component receives data from a component higher up, the data received becomes props to that component that received it. Data can be termed as "state" only in the component that created it, that is if the data cannot be traced to any other component higher up.
Only one component can own a state, that is the component that created it, and its the only component that can change its values, but props are immutable meaning that the values of props cannot be changed. If a component receives a prop called "name" with value of "Jared", the component cannot change the value of the name prop from "Jared" to "Khalil".

About The Author
Emmanuel Ochade, is an experienced Frontend/Backend with special interest in React and a blockchain enthusiast, who is willing to share all his learning and knowledge about react and blockchain with the public.

Top comments (0)