JSPM

react-persisted-global-state

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q11302F
  • License MIT

Simple React hook for global, local storage persisted state.

Package Exports

  • react-persisted-global-state
  • react-persisted-global-state/dist/index.js
  • react-persisted-global-state/dist/react-persisted-global-state.esm.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-persisted-global-state) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-persisted-global-state

License Project Status: Active – The project has reached a stable, usable state and is being actively developed. Depfu npm npm GitHub stars All Contributors

About

Simple React hook for global state which is persisted to Local Storage.

This allows sharing state between multiple components or different instance of the same component, all while the changes are persisted to the browser's Local Storage.

Installing

Install react-persisted-global-state and its peer-dependencies:

# For users of npm
npm install --save react-persisted-global-state react-use

# For users of Yarn
yarn add react-persisted-global-state react-use

Usage

import { createPersistedGlobalState } from 'react-persisted-global-state';

// Register a re-usable instance of our global state store
const useMyPersistedGlobalState = createPersistedGlobalState<string>(
  'my-localstorage-key',
  'Hello, world!'
);

const MyComponent = () => {
  const [state, setState, removeState] = useMyPersistedGlobalState();

  return (
    <input type="text" value={state} onChange={e => setState(e.target.value)} onClear />
  );
};

Releasing

We use release-it to automate our creating releases for this application. A new release can be rolled out by running:

yarn release

✨ Contributors

Thanks goes to these wonderful people (emoji key):


Adriaan Knapen

💻 🔧 📖 ⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!