hardStudy question · answer published in React interview questions, so no pointsreacthooksstrict-mode
Items added twice in development
In development, each ADD dispatch adds the item twice. In production it is fine. What is the bug?
function reducer(state, action) {
if (action.type === "ADD") {
state.items.push(action.item)
return { ...state }
}
return state
}Discussion 0
Join free to post in the discussion.
Related questions
- Why React lists need keysFrontend Developer
- Input that ignores typingFrontend Developer
- Changing a prop inside a childFrontend Developer
- Typo in a variable nameFrontend Developer
- Result type of findFrontend Developer
- What JSX turns intoFrontend Developer
- A component written in lowercaseFrontend Developer
- Adding a CSS class in JSXFrontend Developer