saga-cookie

0.2.3 • Public • Published

Saga-Cookie · GitHub license npm version Coverage Status PRs Welcome

Use Cookie as Redux state. 🍪

Workflow

Installation

npm install saga-cookie

Configuarition

Example

Examples

Usage

Render Cookie from Props

{props.cookie.hello}

Dispatch Cookie

setCookie is just like React's setState

import { setCookie } from 'saga-cookie';
 
// set-cookie
dispatch(setCookie({
  hello: 'hello',
}));
 
dispatch(setCookie((cookie) => {
  return {
    hello: cookie.hello + ' saga cookie!',
  }
}, function () {
  // callback
}));
 
// delete cookie
dispatch(setCookie({
  hello: null,
}));

Force Update

You should avoid to do manual operation to Cookies when using saga-cookie,

use forceUpdate to reload cookies from BOM

import { forceUpdate } from 'saga-cookie';
// force saga-cookie update
dispatch(forceUpdate);

Dependents (0)

Package Sidebar

Install

npm i saga-cookie

Weekly Downloads

1

Version

0.2.3

License

MIT

Unpacked Size

8.9 kB

Total Files

5

Last publish

Collaborators

  • chiaweilee