Skip to content
Advertisement

Tag: use-state

React: How to set a component in ‘active’ state one at a time, and remove ‘active’ from all other component on click?

I want to set a particular component as active on click, and update the active component when some other component is clicked. Currently, both the components are remaining in active state. I want to remove active state from previously clicked component. Answer To make it general, let’s imagine that you have not just two components, but any number of components.

How to replace Array in useState?

I want make program that table content is changed by user’s select. So I put empty array in useState, like this. And select html code: When I select option, data will be changed. But I don’t no how to do it with useState. These are data And my React code: I tried using map. But I don’t know how to

ReactJS useState hook – asynchronous behaviour

I am building a page to list products. So I’ve one input:file button to select multiple images and then I’m calling an API to upload that images on the server and displaying progress in UI with images. Here’s my code. As the useState is asynchronous, I can’t directly pass that react state to my API handler. So now the issue

Advertisement