From the course: Learning Full-Stack JavaScript Development: MongoDB, Node, and React
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
State and event handlers
From the course: Learning Full-Stack JavaScript Development: MongoDB, Node, and React
State and event handlers
- One simple way to understand the big picture of React is to think of the views react vendors in the browser as functions of data and state. You can think of the whole application as a big function of its data and state, but furthermore every React component is a function of some data and some state. Literally a React component is a JavaScript function that takes data as input through its props but it's also driven by an internal state that React manages for every component and it provides an API to work with that. The simplest method to manage a state element in a component is through the use state function. We can import this function from the React package. In any component, a call to this used state function makes React register a state variable for that component. What exactly is a state variable as known in React? Well, it's why React is named React. A state variable can be thought of as a reactive variable. We can…