Problem Statement
Why should you avoid modifying the state directly in React Native?
Explanation
State should only be changed using setState (for class components) or the setter from useState (for functional components). Direct modification won’t trigger a UI re-render and can lead to inconsistent data.
Code Solution
SolutionRead Only
this.setState({ count: this.state.count + 1 });Practice Sets
This question appears in the following practice sets: