Skip to content

Commit

Permalink
updated lib
Browse files Browse the repository at this point in the history
  • Loading branch information
mcrowder65 committed Feb 6, 2019
1 parent 951e343 commit 550802f
Showing 1 changed file with 11 additions and 51 deletions.
62 changes: 11 additions & 51 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,67 +9,27 @@ var _react = _interopRequireDefault(require("react"));

var _store = _interopRequireDefault(require("store"));

function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _slicedToArray(arr, i) {
return (
_arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest()
);
}
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (
var _i = arr[Symbol.iterator](), _s;
!(_n = (_s = _i.next()).done);
_n = true
) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function useLocalStorageSetState(initialValue, name) {
if (!name) {
throw new Error(
"Name must be provided to persist properly to localStorage"
);
throw new Error("Name must be provided to persist properly to localStorage");
}

var actualInitialValue =
_store.default.get(name) !== undefined
? _store.default.get(name)
: initialValue;
var actualInitialValue = _store.default.get(name) !== undefined ? _store.default.get(name) : initialValue;

var _React$useState = _react.default.useState(actualInitialValue),
_React$useState2 = _slicedToArray(_React$useState, 2),
value = _React$useState2[0],
setValue = _React$useState2[1];
_React$useState2 = _slicedToArray(_React$useState, 2),
value = _React$useState2[0],
setValue = _React$useState2[1];

var theirSetValue = function theirSetValue(theirNewValue) {
var valueToSet;
Expand All @@ -89,4 +49,4 @@ function useLocalStorageSetState(initialValue, name) {
}

var _default = useLocalStorageSetState;
exports.default = _default;
exports.default = _default;

0 comments on commit 550802f

Please sign in to comment.