0.2.3 • Published 5 years ago
saga-cookie v0.2.3
Saga-Cookie ·
Use Cookie as Redux state. 🍪
Installation
npm install saga-cookie
Configuarition
Example
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);