showing results for - "toggle react js more items"
Kylie
17 Sep 2018
1import React, {useState} from 'react'
2
3const [toggleItems, setToggleItems] = useState(
4  [
5    {
6    	name: 'First',
7      	active: false
8    },
9    {
10    	name: 'Second'
11      	active: false,
12    }
13  ]
14)
15
16const toggle = () => {
17  setToggleItems(old => old.map(item => {
18  		item.active = !item.active
19    	return item
20  	})
21  )
22}
23
24console.log(toggleItems)