DEV Community

fardinh136
fardinh136

Posted on

state and props in JavaScript.

 Props are used to pass data. Props are used to pass data from parent to child or by the component itself. They are immutable and thus will not be changed. Data from props is read-only, and cannot be modified by a component that is receiving it from outside.
But State is used for mutable data, or data that will change. State is for managing data. State data can be modified by its own component, but is private so it cannot be accessed from outside the box.

Top comments (0)