- 8 hours
- Medium
Free online content available in this course.
course.header.alt.is_video
course.header.alt.is_certifying
Got it!Last updated on 11/8/22
Manage Data in a React App Using State and Effects
Evaluated skills
- Manage data in a React app using state and effects
Question 1
Which of these statements is incorrect?
Local state exists within a component.
However many times this component re-renders, the data will be preserved.
Use local state in a function component with useState.
Update state with
useState(newValue)
.
Question 2
You want to create a
cartValue
local state set to 0 that will let you save the price of items added to the cart.Which syntaxes could you use to get and update your state?
Careful, there are several correct answers.const updateCartValue = useState({ cartValue: 0 })
const cartState = useState(0) const cartValue = cartState[0] const updateCartValue = cartState[1]
const [cartValue, updateCartValue] = useState(0)
const [cartValue, updateCartValue] = useState(1)
Question 3
Which of these statements are true?
Careful, there are several correct answers.useEffect
anduseState
have to be imported from the package "react-hooks."useEffect
anduseState
are the only two hooks that exist.Hooks didn’t exist when React was first created.
A hook is a function that allows us to hook into React functionalities.
- Up to 100% of your training program funded
- Flexible start date
- Career-focused projects
- Individual mentoring