sails-react-store

1.0.9 • Public • Published

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

Package Sidebar

Install

npm i sails-react-store

Weekly Downloads

34

Version

1.0.9

License

MIT

Last publish

Collaborators

  • wi2