In the examples given on React's website, I have a doubt in the Counter App example. I'm confused with how do I assign states in the app. Does each item is assigned a state & how to update the state using setState() ?
What should be the thinking process?
Please help. Thank you!
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (2)
hi @shah-ms.
A state can contain a lot of data depending on your app. You can retrieve data from an API and you can store data for your app.
Using state hooks and using
this.state
andthis.setState
are common ways to handle state management in React.Have you looked at React hooks? reactjs.org/docs/hooks-state.html
I feel like that makes state handling way easier. In new codebases I even have the rule to only add functional components and use hooks, instead of class-based components.