source: imaps-frontend/node_modules/react-use/esm/useCookie.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 609 bytes
Line 
1import { useCallback, useState } from 'react';
2import Cookies from 'js-cookie';
3var useCookie = function (cookieName) {
4 var _a = useState(function () { return Cookies.get(cookieName) || null; }), value = _a[0], setValue = _a[1];
5 var updateCookie = useCallback(function (newValue, options) {
6 Cookies.set(cookieName, newValue, options);
7 setValue(newValue);
8 }, [cookieName]);
9 var deleteCookie = useCallback(function () {
10 Cookies.remove(cookieName);
11 setValue(null);
12 }, [cookieName]);
13 return [value, updateCookie, deleteCookie];
14};
15export default useCookie;
Note: See TracBrowser for help on using the repository browser.