Replace map with forEach

`forEach` is more semantically correct to use in the MultiselectCheckbox example.

Codesandbox with `forEach` https://codesandbox.io/s/30-seconds-of-react-multiselectcheckbox-tk9qf
This commit is contained in:
iamdi
2019-06-23 08:59:25 +10:00
committed by GitHub
parent 661972f8f8
commit 8e084d3412

View File

@ -23,7 +23,7 @@ function MultiselectCheckbox({ options, onChange }) {
const [data, setData] = React.useState(options);
const toggle = item => {
data.map((_, key) => {
data.forEach((_, key) => {
if (data[key].label === item.label) data[key].checked = !item.checked;
});
setData([...data]);