Ejemplo n.º 1
0
var omniscient = require('omniscient');

const jsx = true;
const component = omniscient.withDefaults({ jsx });

// component.debug();

export default component;
import omniscient from 'omniscient';

const component = omniscient.withDefaults({
  isIgnorable: (_, key) => key == 'dispatch'
});

component.debug();

export default component;
Ejemplo n.º 3
0
var React = require("react");
var omniscient = require("omniscient");
var component = omniscient.withDefaults({ jsx: true });

// Omniscient components are primarily stateless and have just a render method.
// Create a mixin to implement with React methods.
var withInitialState = {
    getInitialState: function () {
        return {
            ts: new Date().getTime(),
            selectedVariationSku: this.props.accessory.get("variationSkuInCart") ||
                this.props.accessory.get("selectedProductSku")
        };
    }
};

// Component = (optional) name, [mixins], render method
var Accessory = component("Accessory", [withInitialState], function(props) {

    // Turn the Immutable Map into a JS object to have easier access to properties
    var accessory = props.accessory.toObject();
    var self = this;

    var selectVariationFn = (sku) => (
      () => this.setState({ selectedVariationSku: sku }));

    var toggleProductFn = () => {
        this.setState({ ts: new Date().getTime() });
        props.accessory.update("variationSkuInCart", (oldSku) => {
            var currentSku = this.state.selectedVariationSku;
            return (oldSku === currentSku) ? null : currentSku;  // remove : add