I need to make a resizable text area that persists with its size even when the page is reloaded, but it just doesn't work.
I tried to use local storage to store the text area height and width that is within one array, and when the page is reloaded, turn the text area size into the stored one.
let initialSize = [textarea.clientHeight, textarea.clientWidth];
localStorage.setItem("storedSize", initialSize);
const storedSize = localStorage.getItem("storedSize");
if (storedSize) {
initialSize = storedSize;
}
but it just doesn't work because storing an array in local storage just isn't possible and i dont know why.
According to this page on MSDN Web Docs, local storage can only store STRINGS, as key->value pairs. To store an array, you either need to store the values separately as individual key->value pairs, or convert the array to a string before storing it.