Last active
April 8, 2020 17:22
-
-
Save guigaoliveira/9ed50378cf4097f067967a460dc19537 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getState = () => ({ | |
labels: [ | |
'Red', | |
'Green', | |
'Yellow', | |
'Surprise' | |
], | |
datasets: [{ | |
data: [0, 0, 0, 0], | |
backgroundColor: [ | |
'#FF6384', | |
'#36A2EB', | |
'#FFCE56', | |
'#ABCDEF' | |
], | |
hoverBackgroundColor: [ | |
'#FF6384', | |
'#36A2EB', | |
'#FFCE56', | |
'#ABCDEF' | |
] | |
}] | |
}); | |
this.setState((prevState) => ({ | |
...prevState, | |
datasets: prevState.datasets.map(obj => { | |
const [first, ...rest] = obj.data | |
return ({ ...obj, data: [first + 1, ...rest] }) | |
}) | |
}) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment