0.7.3 • Published 6 years ago

refrax-react v0.7.3

Weekly downloads
6
License
BSD-3-Clause
Repository
github
Last release
6 years ago

refrax-react npm version

Official React bindings for Refrax.

Installation

Refrax React requires React 0.13 or later.

npm install --save refrax-react

Basic Usage

import { createSchema, createSchemaCollection } from 'refrax'
import { createContainer } from 'refrax-react'
import { Component } from 'react'

const schema = createSchema();
schema.addLeaf(createSchemaCollection('users'));

class HelloWorldComponent extends Component {
  render() {
    return (
      <div>
        <h4>Users</h4>
        <ul>
          {this.showUsers()}
        </ul>
      </div>
    )
  }

  showUsers() {
    if (this.isLoading()) {
      return "...Loading..."
    }

    return this.props.users.map((user, i) => (
      <li key={i}>{user.name}</li>
    ))
  }
}

const HelloWorld = createContainer(HelloWorldComponent, function() {
  return {
    users: schema.users
  }
});

License

Refrax React is BSD licensed.