All Projects → antonybudianto → react-save-localstorage

antonybudianto / react-save-localstorage

Licence: MIT license
🗄 React component to save data to localStorage on render phase safely

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-save-localstorage

react-local-storage-cache
How to cache results in React with Local Storage.
Stars: ✭ 27 (+3.85%)
Mutual labels:  localstorage, local-storage
stickyard
Make your React component sticky the easy way
Stars: ✭ 83 (+219.23%)
Mutual labels:  render-props
Vellum
Vellum is local persistent data storage for iOS
Stars: ✭ 16 (-38.46%)
Mutual labels:  localstorage
Lowdb
Simple to use local JSON database (supports Node, Electron and the browser)
Stars: ✭ 16,886 (+64846.15%)
Mutual labels:  localstorage
react-localstorage
Easy methods for use localstorage in Reactjs.
Stars: ✭ 21 (-19.23%)
Mutual labels:  localstorage
keyv
Simple key-value storage with support for multiple backends.
Stars: ✭ 202 (+676.92%)
Mutual labels:  localstorage
form-saver
A simple script that lets users save and reuse form data.
Stars: ✭ 67 (+157.69%)
Mutual labels:  localstorage
localForage-cn
localForage中文仓库,localForage改进了离线存储,提供简洁健壮的API,包括 IndexedDB, WebSQL, 和 localStorage。
Stars: ✭ 201 (+673.08%)
Mutual labels:  localstorage
render-props
㸚 Easy-to-use React state containers which utilize the render props (function as child) pattern
Stars: ✭ 33 (+26.92%)
Mutual labels:  render-props
jsGBC
👾 A GameBoy Color Emulator written in JavaScript
Stars: ✭ 44 (+69.23%)
Mutual labels:  localstorage
reason-epitath
CPS sugar usage for React Render Props composition in ReasonML
Stars: ✭ 16 (-38.46%)
Mutual labels:  render-props
effectiveweb.training
Repository for Effective Web Online Course / airhacks.io
Stars: ✭ 17 (-34.62%)
Mutual labels:  local-storage
redebounce
↘️ Render Props component to debounce the given value
Stars: ✭ 14 (-46.15%)
Mutual labels:  render-props
cache-bucket
Light Cache for nodeJs and browserJs with TTL.
Stars: ✭ 14 (-46.15%)
Mutual labels:  localstorage
vue-storage-watcher
a reactive storage plugin for vue 👀🔭
Stars: ✭ 60 (+130.77%)
Mutual labels:  localstorage
mst-persist
Persist and hydrate MobX-state-tree stores (in < 100 LoC)
Stars: ✭ 75 (+188.46%)
Mutual labels:  localstorage
BlazoredLocalStorage
This library has been moved to the Blazored org
Stars: ✭ 26 (+0%)
Mutual labels:  localstorage
groucho
Know all your users. Scalable front-end (anon) personalization & attribution
Stars: ✭ 31 (+19.23%)
Mutual labels:  localstorage
local-storage-fallback
Check and use appropriate storage adapter for browser (localStorage, sessionStorage, cookies, memory)
Stars: ✭ 103 (+296.15%)
Mutual labels:  localstorage
Covid19-Tracker
The situation of the Coronavirus epidemic data around the World and details info in Vietnam.
Stars: ✭ 15 (-42.31%)
Mutual labels:  localstorage

react-save-localstorage

npm version Build Status

Save and sync your data on render phase to localStorage safely

Try it live at StackBlitz

import React, { Component } from 'react';
import SaveLocalStorage from 'react-save-localstorage';

class Home extends Component {
  state = {
    email: ''
  };
  render() {
    return (
      <div>
        {/* Mode 1: read only */}
        <SaveLocalStorage lsKey="lang">
          {lang => <div>Language: {lang || '-'}</div>}
        </SaveLocalStorage>

        {/* Mode 2: write only */}
        <SaveLocalStorage lsKey="emailBackup" value={this.state.email} />

        {/* Mode 3: dual */}
        <SaveLocalStorage value={this.state.email} lsKey="email">
          {v => (
            <div>
              <input
                value={v}
                onChange={e =>
                  this.setState({
                    email: e.target.value
                  })
                }
              />
              <div>Welcome, {v || 'Guest'}</div>
            </div>
          )}
        </SaveLocalStorage>
      </div>
    );
  }
}

Props

  • lsKey (string, required)

  • value (string)

  • sync (bool)

    To sync after value updates, default is true

  • children (func)

    Function that accept loaded value from localStorage

  • onSave (func)

    Function that accept object containing:

    • init (boolean that indicated it's the first mount)
    • value (the value being saved)

    This is called for every value updates.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].