main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
798 bytes
|
Line | |
---|
1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | var tslib_1 = require("tslib");
|
---|
4 | var react_1 = require("react");
|
---|
5 | var js_cookie_1 = tslib_1.__importDefault(require("js-cookie"));
|
---|
6 | var useCookie = function (cookieName) {
|
---|
7 | var _a = react_1.useState(function () { return js_cookie_1.default.get(cookieName) || null; }), value = _a[0], setValue = _a[1];
|
---|
8 | var updateCookie = react_1.useCallback(function (newValue, options) {
|
---|
9 | js_cookie_1.default.set(cookieName, newValue, options);
|
---|
10 | setValue(newValue);
|
---|
11 | }, [cookieName]);
|
---|
12 | var deleteCookie = react_1.useCallback(function () {
|
---|
13 | js_cookie_1.default.remove(cookieName);
|
---|
14 | setValue(null);
|
---|
15 | }, [cookieName]);
|
---|
16 | return [value, updateCookie, deleteCookie];
|
---|
17 | };
|
---|
18 | exports.default = useCookie;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.