localstorage in next js
import { FunctionComponent, createElement, useState, MouseEvent, useEffect } from 'react'
interface Props {
type: string
}
const CleanupLocalStorage: FunctionComponent<Props> = (props: Props) => {
const LocalStorage = ({ type }): void => {
switch (type) {
case 'clear':
type !== undefined && window.localStorage.clear()
break
default:
alert('localStorage type undefined')
break
}
}
useEffect(() => {
LocalStorage(props)
},[])
return <></>
}
export default CleanupLocalStorage