@fcannizzaro/react-use-cookie-watcher

react hook to watch browser cookies

Usage no npm install needed!

<script type="module">
  import fcannizzaroReactUseCookieWatcher from 'https://cdn.skypack.dev/@fcannizzaro/react-use-cookie-watcher';
</script>

README

@fcannizzaro/react-use-cookie-watcher

react hook to watch browser cookies

NPM JavaScript Style Guide

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