Cookie
cookieBackend
is the wrapper of js-cookie
Hooks
const ComponentWithCookieBackend = () => {const { cookieBackend } = useGlobal();// ... your code};
Saga
import { getContext } from 'redux-saga/effects';export function* functionWithCookieBackend() {const { cookieBackend } = yield getContext('useGlobal');// ... your code}
Apis
# Get a cookie valuecookieBackend.get("name");// Set a string to namecookieBackend.set("name", "string value");// return number or undefinedcookieBackend.getInt("name");
Best practices
Cookie will send data it contains back to server in every request, so do not store more data than you need in cookie.