zordius/fluxex

View on GitHub
examples/01-history-api/components/Product.jsx

Summary

Maintainability
A
3 hrs
Test Coverage
var React = require('react');
var Fluxex = require('fluxex');

var Product = React.createClass({
    mixins: [
        Fluxex.mixin,
        require('fluxex/extra/storechange'),
        {listenStores: ['productStore']}
    ],

    getStateFromStores: function () {
        return this.getStore('productStore').getProduct();
    },

    render: function () {
        return (
        <div>
         <h3>{this.state.title}</h3>
         <p>{this.state.description}</p>
         <span>{'Price:'+this.state.price}</span>
         <ul>
          <li>{'data generated time:'+this.state.time}</li>
          <li>{'Serial(random):'+this.state.serial}</li>
         </ul>
         <h4>Related products</h4>
         <ul>
          <li><a href="/product?id=123">ID = 123</a></li>
          <li><a href="/product?id=456">ID = 456</a></li>
          <li><a href="/product?id=789">ID = 789</a></li>
         </ul>
        </div>
        );
    }
});

module.exports = Product;