Giter VIP home page Giter VIP logo

react-localforage's Introduction

react-localforage

Declarative localForage in React

npm version Build Status codecov

Install

npm install -S react-localforage
import Forage from 'react-localforage'

API

Forage.GetItem

<Forage.GetItem
  itemKey='auth-token'
  render={({inProgress, value, error}) => {
    return (
      <div>
        {error &&
        <div>
          {error.message}
        </div>}
        {inProgress && <progress/>}
        {value &&
         <pre>{JSON.stringify(value, null, 2)}</pre>}
      </div>
    )
  }}
/>

Forage.SetItem

<Forage.SetItem
  itemKey='auth-token'
  itemValue={authToken}
  render={({inProgress, value, error}) => {
    return (
      <div>
        {error &&
        <div>
          {error.message}
        </div>}
        {inProgress && <progress/>}
        {value &&
        <div>
          {value}
        </div>}
      </div>
    )
  }}
/>

react-localforage's People

Contributors

peterpme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

peterpme aka-jain

react-localforage's Issues

componentWillMount vs componentDidMount

Hi,

Don't know if this is the right place to ask this kind of question, but i will take the risk.

I have a question related to this piece of code:

this.getValue()

Can you explain why this call was made in componentWillMount as opposed to componentDidMount?

Can you talk about pros and cons?

Thank you.

Use hooks instead of component

It would be much more convenient and readable (and probably better performance) if we could do something like this:

const Component = () => {
  const [value, setValue] = useLocalForage('key')
}

React 16.3

Any knowledge of if this package works with 16.3?

I could make a PR and give it a shot if that is unknown and you are willing.

Looks like exactly what I need but I want to know its still active ;-)

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.