@kuzmycz/react-cache
TypeScript icon, indicating that this package has built-in type declarations

1.1.6 • Public • Published

react-cache

Cache content and get notified when content changes

NPM JavaScript Style Guide gzip size

Install

npm install --save @kuzmycz/react-cache

Usage

import * as React from 'react'

import {Cache} from 'react-cache'

const App = () => {
  return (
    <div>
      <div>Test</div>
      <Cache values={{}}>
        <Address name={'buyer'}/>
      </Cache>
    </div>
  )
};

const Address = ({name}) => {
  const [street, setStreet] = useCacheValue(`${name}.street`)
  const [city, setCity] = useCacheValue(`${name}.city`)
  const [state, setState] = useCacheValue(`${name}.state`)
  const [country, setCountry] = useCacheValue(`${name}.country`)
  const [postcode, setPostcode] = useCacheValue(`${name}.postcode`)

  return (<div>
    <label>
      Street:
      <input type='text' value={street} onChange={(e) => setStreet(e.target.value)} />
    </label>
    <label>
      City:
      <input type='text' value={city} onChange={(e) => setCity(e.target.value)} />
    </label>
    <label>
      State:
      <input type='text' value={state} onChange={(e) => setState(e.target.value)} />
    </label>
    <label>
      Country:
      <input type='text' value={country} onChange={(e) => setCountry(e.target.value)} />
    </label>
    <label>
      Postcode:
      <input type='text' value={postcode} onChange={(e) => setPostcode(e.target.value)} />
    </label>
  </div>)
}

License

MIT © kuzmycz

Readme

Keywords

none

Package Sidebar

Install

npm i @kuzmycz/react-cache

Weekly Downloads

1

Version

1.1.6

License

MIT

Unpacked Size

69 kB

Total Files

20

Last publish

Collaborators

  • kuzmycz