3.4.1 • Published 4 years ago

@react-x/storage v3.4.1

Weekly downloads
19
License
MIT
Repository
github
Last release
4 years ago

@react-x/storage

npm npm npm

Cross-platform storage for ReactDOM and React Native apps.

Getting Started

Install @react-x/storage using yarn:

yarn add @react-x/storage

Usage

import React from 'react';
import PropTypes from 'prop-types';
import {Text, Touchable, View} from 'react-native';
import Storage from '@react-x/storage';


class App extends React.Component {

  // --------------------------------------------------
  // Props
  // --------------------------------------------------
  static propTypes = {
    user: PropTypes.object.isRequired,
  };

  static defaultProps = {
  };

  // --------------------------------------------------
  // Event Handlers
  // --------------------------------------------------

  @bind
  async handlePress() {
    Storage.setItem('name', this.props.user.name);
  }

  // --------------------------------------------------
  // Render
  // --------------------------------------------------
  render() {
    return (
      <View>
        ...
        <Touchable
          onPress={this.handlePress}>
          <Text>
            {'Copy Name'}
          </Text>
        </Touchable>
      </View>
    );
  }

}

API

async setItem(key, value)

Sets a key / value pair within the storage container.

async getItem(key)

Gets a specified key from the storage container.

Contributing

If you have any ideas on how this module could be better, create an Issue or submit a PR.

3.4.1

4 years ago

3.4.0

4 years ago

3.3.0

4 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.0

5 years ago