0.8.1 • Published 5 years ago

react-connex v0.8.1

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

react-connex

Simple higher-order component (HOC) providing a Connex context to React app.

Detects whether the user is using Sync or a Comet wallet-enabled browser.

Installation

$ yarn add react-connex

Basic Usage

Add the `ConnexProvider to your root React Component;

import ConnexProvider from 'react-connex';

<ConnexProvider
  loading="Loading..."
  error={err => `Connection error: ${err}`}>
  <App />
</ConnexProvider>

Then in the component where you want to use Connex:

import { withConnex } from 'react-connex';

class MyComponent {
  render() {
    const { connex } = this.props;
    const status = connex.thor.status;

    return status.progress;
  }
}

export default withConnex(MyComponent);

You can use the injected getNetwork property to get network details:

import { withConnex } from 'react-connex';

class MyComponent {
  render() {
    const { getNetwork } = this.props;
    getNetwork().then(network => {
      return `${network.id} and ${network.name}`
    });
  }
}

export default withConnex(MyComponent);
0.8.1

5 years ago

0.8.0

5 years ago

0.7.0

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago