Self review: Managing state in React

A passionate full-stack developer from @ePlus.DEV
Search for a command to run...

A passionate full-stack developer from @ePlus.DEV
No comments yet. Be the first to comment.
In this module you will explore the basic structure and use of the React.js library. You will learn how to produce single page web applications using React components and to use JSX to style them.
What is the Context API? An alternative way to working with state in React. A way to change the execution context of a function in JavaScript. When working with useState to keep state in a variable, you should not use array destructuring. True ...
Challenge overview In a challenge lab you’re given a scenario and a set of tasks. Instead of following step-by-step instructions, you will use the skills learned from the labs in the course to figure

Một bản tin giúp Developer cập nhật nhanh AI, Cloud, Open Source và những công nghệ đáng chú ý trong ngày. 📌 Executive Summary OpenAI công bố mười kết quả mới cho các bài toán lâu năm trong toán h

Một bản tin giúp Developer cập nhật nhanh AI, Cloud, Open Source và những công nghệ đáng chú ý trong ngày. 📌 Executive Summary OpenAI công bố mười kết quả mới cho các bài toán lâu năm trong toán h

Một bản tin giúp Developer cập nhật nhanh AI, Cloud, Open Source và những công nghệ đáng chú ý trong ngày. 📌 Executive Summary GitHub thử nghiệm policy theo enterprise team, cho phép cấp thêm mode

Một bản tin giúp Developer cập nhật nhanh AI, Cloud, Open Source và những công nghệ đáng chú ý trong ngày. 📌 Executive Summary OpenAI giảm mạnh giá GPT-5.6 Luna và Terra, đồng thời chuyển Priority

True or false? When lifting state up, you need to move the useState from a child component to a parent component.
True.
False.
If the state variable holds an array or a string value, once you pass that state via props from a parent to a child, you can then read the length property from the received prop in the child component.
True
False
What's wrong with this code?
import React from "react";
import Fruits from "./Fruits";
import FruitsCounter from "./FruitsCounter";
function App() {
const [fruits] = useState([
{fruitName: 'apple', id: 1},
{fruitName: 'apple', id: 2},
{fruitName: 'plum', id: 3},
]);
return (
<div className="App">
<h1>Where should the state go?</h1>
<Fruits fruits={fruits} />
<FruitsCounter fruits={fruits} />
</div>
);
}
export default App;
If you don't add the setFruits state-updating function when descructuring values from useState, the app won't compile.
There's nothing wrong with the provided code.
The useState call should be React.useState.