Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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
 
PREVIOUS NEXT
Tagged: #localstorage #js
ADD COMMENT
Topic
Name
1+3 =