“LOCALSTORAGE NEXTJS” Code-Antworten

NEXTJS LOCALSTORAGE

useEffect(() => {
    // setter
    localStorage.setItem('myData', data);
    // getter
    localStorage.getItem('myData');
    // remove
    localStorage.removeItem('myData');
    // remove all
    localStorage.clear();
}, [])
Radmehr Aghdam

LOCALSTORAGE NEXTJS

/*
	Next JS runs your code twice making using window impossible
    So you can do this
*/

window?.localStorage?.whatever()
Homeless Hedgehog

Ähnliche Antworten wie “LOCALSTORAGE NEXTJS”

Fragen ähnlich wie “LOCALSTORAGE NEXTJS”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen