I have stored all the values in state called data as below:
loadValues = () => {
this.setState({
data: [`{"Price:" "${this.state.price}","Title": "${this.state.title}","MenuId": "${this.state.code}","Quantity": "${this.state.counter}"}`],
})
}
Now i need help in storing these values in sessionStorage and print it in console.(reactJs). Thanks in advance.
You can only do like the following:
loadValues = () => {
this.setState({
data: [`{"Price:" "${this.state.price}","Title": "${this.state.title}","MenuId": "${this.state.code}","Quantity": "${this.state.counter}"}`],
}, () => {
sessionStorage.setItem('data', this.state.data)
})
}