How to use the fusion-react.prepared function in fusion-react

To help you get started, we’ve selected a few fusion-react examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fusionjs / fusionjs / fusion-plugin-rpc-redux-react / src / __tests__ / index.browser.js View on Github external
message: e.message,
            // $FlowFixMe
            code: e.code,
            // $FlowFixMe
            meta: e.meta,
            initialArgs: {hello: 'world'},
          },
          'dispatches failure with correct payload'
        );
        return {
          ...action.payload,
          loading: false,
        };
      },
    }),
    prepared(props =>
      props.message ? Promise.resolve() : props.test({hello: 'world'})
    ),
    connect(s => s)
  );

  const element = React.createElement(
    Provider,
    {store},
    React.createElement(hoc(Component))
  );
  const app = new App(element);
  app.register(Plugin);
  app.register(FetchToken, fetch);
  await getSimulator(app)
    .render('/')
    .catch(e => t.equal(e.message, 'Some failure'));
github fusionjs / fusionjs / fusion-plugin-rpc-redux-react / src / __tests__ / index.browser.js View on Github external
// $FlowFixMe
      fixture.payload,
      'dispatches expected action payload'
    );
    return action.payload;
  }, null);

  const Component = props => {
    t.equal(typeof props.test, 'function', 'passes correct prop to component');
    return React.createElement('span', null, 'hello world');
  };

  const withTest = compose(
    withRPCRedux('test'),
    connect(s => s),
    prepared(props =>
      props.message ? Promise.resolve() : props.test({hello: 'world'})
    )
  )(Component);

  const element = React.createElement(
    Provider,
    {store},
    React.createElement(withTest)
  );
  const app = new App(element);
  app.register(Plugin);
  app.register(FetchToken, fetch);
  await getSimulator(app)
    .render('/')
    .catch(e => t.equal(e.message, 'message'));
  t.equal(expectedActions.length, 0, 'dispatches all actions');
github KevinGrandon / fusion-boilerplate / redux-boilerplate / src / pages / styles.js View on Github external
class RPC extends React.Component {
  render() {
    const {name} = this.props;
    console.log('What props do we get', this.props.name);
    return <div>RPC DEMO {name}</div>;
  }
}

//export default RPC;
const preparedFunc = async (props, context) =&gt; {
  console.log('What props', context);
  const response = await Axios.get('http://localhost:3000/api/user/1');
  console.log('AFTER PROMISEResponse come back', response.data);
  return {...response.data};
};
export default prepared(preparedFunc, {forceUpdate: true})(RPC);

// export default Styles;

fusion-react

FusionJS entry point for React universal rendering

MIT
Latest version published 2 years ago

Package Health Score

54 / 100
Full package analysis

Similar packages