React view isomorph with socket.io for sailsjs
JavaScript
Latest commit ecc3da1 Sep 5, 2015 @wi2 fix and new release
Permalink
Failed to load latest commit information.
dist fix and new release Sep 5, 2015
src fix and new release Sep 5, 2015
test fix, refactor and new Release Sep 3, 2015
.gitignore first commit Jul 2, 2015
.npmignore first commit Jul 2, 2015
.travis.yml travis :add babel install Jul 18, 2015
LICENSE Initial commit Jul 2, 2015
README.md fix and new release Sep 5, 2015
index.js compile es5 dist Jul 5, 2015
package.json fix and new release Sep 5, 2015

README.md

Sails React

Installation

You need sais.io.socket and sails-hook-babel

$ npm install sails-react-store sails-hook-babel --save

Usage

for record's collection

"use strict";
import React from 'react'
import {ReactItem, ReactCollection} from 'sails-react-store'

export class PostItem extends ReactItem {
  render() {
    return (
      <div className="post">
        <h5 className="post-title">{this.state.item.title}</h5>
        <p className="post-content">{this.state.item.content}</p>
      </div>
    )
  }
}

//
//

class Item {
  render() {
    return (
      <span className="doc-title">{this.props.item.title}</span>
    )
  }
}

export class PostCollection extends ReactCollection {
  render() {
    return (
      <div className="posts">
        {this.state.items.map( (item,i) => {
          return <Item item={item} key={i} />;
        })}
      </div>
    )
  }
}

and use like that when no attributes items => get request /post

<PostCollection identity="post" />

or if you want to add manually items

<PostCollection identity="post" items={[]} />

for one record

<PostItem identity="post" item={{title:'a title', content: 'a text content'}} />

License

MIT © 2015 contributors