DEV Community

Cover image for Props and State in React Components
Engr. Promise
Engr. Promise

Posted on

1

Props and State in React Components

It is essential you have a good understanding of props and States in both functional and class components. props influences what is rendered in the screen. props are optional input that your components can accept and allows the components to be dynamic.
Props and State holds information that influences the UI in your browser.
Props is just an object that contains the attributes and their values which has been passed from their parent components.
Props are immutable. Since they are immutable how do we maintain components data that might change over time? The answer lies in using State.

Components States.
Another way to influence what is rendered on the screen is the state of the components.

✓Props get passed to the components while state is managed within the component.
✓Props are functions parameters whereas the state are variables declared in the function body.
✓Props immutable Warehouse States can be changed.
✓In functional components props are assessed using the "props" parameter and in-class components using "this.props", where is estate they are assessed using the useState Hook in functional components and "this.state" in class components.

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More