@devhammed/use-cookie
Get, Set, Update and Delete Cookie using React Hooks.
Install
npm install --save @devhammed/use-cookie
Usage
import React from 'react'
import ReactDOM from 'react-dom'
import useCookie from '@devhammed/use-cookie'
const App = () => {
const [username, setUsername, deleteUsername] = useCookie('username', 'User')
return (
<section>
<h1>Hello {username}!</h1>
<p>Edit below input, Your name will be stored in a cookie. you can refresh this page to see how it persists.</p>
<input
type='text'
value={username}
onChange={(e) => setUsername(e.target.value)}
/>
<button
onClick={() => deleteUsername()}
>
Delete Cookie
</button>
</section>
)
}
ReactDOM.
…