I am trying to use save some data in localstorage. Here I am trying ,
let marks = localstorage.getItem('marks') || []
Here Now, I am trying to add elements into this array using some action.
const addMarks = () => {
localstorage.setItem('marks', ['10'])
}
Then I am using this variable to render the marks like
marks.map((index, mark) => {
return <h1>mark</h1>
})
But this way it does not work as localstorage
only supports the string as a value
.
How do I implement this ?