Props and state
Before we go into the practical, we should know what is state and what is props in React. In ReactJs, components translate your raw data into Rich HTML with the help of JSX, the props and state together build with that raw data to keep your UI consistent. Okay, let's identify what exactly it is:
-
Props and state are both plain JS objects.
-
They are triggered by a render update.
-
React manages the component state by calling setState (data, callback). This method will merge data into this state and rerenders the component to keep our UI up to date. For example, the state of the drop-down menu (visible or hidden).
-
React component props (properties) that don't change over time, for example, drop-down menu items. Sometimes ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access