MCPcopy Create free account
hub / github.com/developit/state-machine-component / Machine

Function Machine

src/index.js:4–13  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2
3export default (reducer, render) => {
4 function Machine() {
5 Component.call(this);
6 let cache = {};
7 let action = type => cache[type] || (cache[type] = data => {
8 this.setState(reducer(this.state, { type, data, props: this.props }));
9 });
10 this.render = (props, state) => render(state, action);
11 this.componentWillReceiveProps = action('@@PROPS');
12 this.componentWillMount = action('@@INIT');
13 }
14 return (Machine.prototype = new Component()).constructor = Machine;
15};

Callers

nothing calls this directly

Calls 1

actionFunction · 0.85

Tested by

no test coverage detected