How to use the react-redux.connect.apply function in react-redux

To help you get started, we’ve selected a few react-redux 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 zeit / next.js / examples / with-rematch / shared / utils / withRematch.js View on Github external
export default (...args) => Component => {
  // First argument is initStore, the rest are redux connect arguments and get passed
  const [initStore, ...connectArgs] = args
  // Connect page to redux with connect arguments
  const ConnectedComponent = connect.apply(null, connectArgs)(Component)

  const ComponentWithRematch = (props = {}) => {
    const { store, initialProps, initialState, ...others } = props

    // Wrap with redux Provider with store
    // Create connected page with initialProps
    return React.createElement(
      Provider,
      {
        store:
          store && store.dispatch
            ? store
            : getOrCreateStore(initStore, initialState)
      },
      React.createElement(ConnectedComponent, { ...initialProps, ...others })
    )
github studiometa / react-next-starter / store / withRedux.js View on Github external
const ComponentWithRedux = (props = {}) => {
    const { store, initialProps, initialState } = props;

    // Connect page to redux with connect arguments
    const ConnectedComponent = connect.apply(null, connectArgs)(Component);

    // Wrap with redux Provider with store
    // Create connected page with initialProps
    return React.createElement(
      Provider,
      { store: store && store.dispatch ? store : getOrCreateStore(initStore, initialState) },
      React.createElement(ConnectedComponent, initialProps),
    );
  };
github Brooooooklyn / redux-epics-decorator / src / testbed.ts View on Github external
return (...args: any) => {
      const originalDispatch = args[1] || {}
      const module = this.getInstance(effectModule)
      Object.assign(originalDispatch, module.allDispatch)
      args[1] = originalDispatch
      return reactConnect.apply(null, args)
    }
  }
github react-native-community / react-native-directory / components / withData.js View on Github external
const composeComponentWithData = mapStateToProps => ComposedComponent => {
  const connectedComponent = connect.apply(null, [mapStateToProps])(ComposedComponent);

  return class WithDataHigherOrder extends Component {
    static async getInitialProps(ctx) {
      let initialState = INITIAL_STATE;

      if (ctx.query) {
        initialState.queryTopic = ctx.query.topic ? ctx.query.topic : undefined;
        initialState.querySearch = ctx.query.search ? ctx.query.search : '';
        initialState.libraries = ctx.query.libraries ? ctx.query.libraries : [...data.libraries];
        initialState.sortBy = ctx.query.sortBy ? ctx.query.sortBy : 'updated';
        initialState.support = ctx.query.support
          ? {
              ...initialState.support,
              ...ctx.query.support,
            }
          : INITIAL_STATE.support;