React State vs React Props

Codify With MeCodify With Me
1 min read

Props or properties are the inputs or the arguments passed to a component. State, on the other hand, is the internal data managed by a component that can change over time. So, Props are like function arguments and state is like local variables inside a function.

Treat props as immutable which means read only. Even if you try to change it, nothing is gonna happen. But it's anti-pattern in React. This is based on functional programming principles.

State, on the other hand is mutable. And, that's the whole purpose of using state variables. We want to tell React that this component has data that can change over time.

One common thing - Anytime state or props change, React will cause a re-render and update the DOM accordingly.

0
Subscribe to my newsletter

Read articles from Codify With Me directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Codify With Me
Codify With Me