1.0.3 • Published 3 years ago

react-use-persistent-state v1.0.3

Weekly downloads
20
License
-
Repository
-
Last release
3 years ago

A react hook that stores your states to LocalStorage. It uses the localforage module to get and set the value.

Example:

const TestComponent = () => {
  const defaultValue = 1;
  const [value, setValue, hydrated] = usePersistentState(
    "storageKey",
    defaultValue
  );
  return <div onClick={() => setValue(value + 1)}>{value}</div>;
};

The hydrated variable is to check whether the hook has retrieved the stored value from LocalStorage on initial mount.

1.0.3

3 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago