README
@fcannizzaro/react-use-cookie-watcher
react hook to watch browser cookies
Install
yarn add @fcannizzaro/react-use-cookie-watcher
Usage
import React, { Component } from 'react'
import { useCookieWatcher, useCookie } from '@fcannizzaro/react-use-cookie-watcher'
const Example = () => {
// cookie existence
const isNotExpired = useCookieWatcher('react-cookie', 500);
// cookie value
const cookie = useCookie('react-cookie');
return <div>cookie {isNotExpired ? 'found' : 'not found'}</div>
}
License
MIT © fcannizzaro