How to use the react-redux.connectAdvanced 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 FactorialComplexity / react-redux-controllers / src / Container.js View on Github external
warning(`Property 'mapper' expected but not found.`)
        return nextOwnProps
      }

      let nextResult = Object.assign({ }, nextOwnProps)
      delete nextResult.mapper // Do not pass the mapper down

      nextResult = mapper(state, nextResult)

      if (!shallowEqual(result, nextResult)) { result = nextResult }

      return result
    }
  }

  return withMapper(connectAdvanced(factory)(WrappedComponent), ...mappings)
}
github elastic / kibana / x-pack / plugins / canvas / public / components / element_wrapper / index.js View on Github external
filter: element.filter,
        expression: element.expression,
      },
    };

    // update props only if something actually changed
    if (!isEqual(result, nextResult)) {
      result = nextResult;
    }

    return result;
  };
}

export const ElementWrapper = compose(
  connectAdvanced(selectorFactory),
  withPropsOnChange(
    (props, nextProps) => !isEqual(props.element, nextProps.element),
    props => {
      const { element, createHandlers } = props;
      const handlers = createHandlers(element, props.selectedPage);
      // this removes element and createHandlers from passed props
      return { handlers };
    }
  ),
  mapProps(props => {
    // remove element and createHandlers from props passed to component
    // eslint-disable-next-line no-unused-vars
    const { element, createHandlers, selectedPage, ...restProps } = props;
    return restProps;
  })
)(Component);
github relax / relax / lib / shared / screens / admin / shared / components / page-builder / canvas / page-element / index.js View on Github external
}

    ownProps = nextOwnProps;
    state = nextState;

    // change result if needed
    if (needsUpdate) {
      result = Object.assign({}, ownProps, updatable, info);
    }

    return result;
  };
}

// Connected element
const ConnectedPageElement = connectAdvanced(selectorFactory)(PageElement);

export default ConnectedPageElement;
github keajs / kea / src / kea / index.js View on Github external
setCache(joinedPath, { actions })
        }

        // if the props did not change, return the old cached output
        if (!result || !shallowEqual(lastProps, nextProps)) {
          lastProps = nextProps
          result = Object.assign({}, nextProps, { actions, dispatch })
        }

        return result
      }
    }

    // connect this function to Redux
    const KonnektedKlass = connectAdvanced(selectorFactory, { methodName: 'kea' })(Klass)

    // If we were wrapping a stateless functional React component, add the plugin code to the connected component.
    if (isStateless(Klass)) {
      plugins.injectToConnectedClass.forEach(f => f(input, output, KonnektedKlass))
    }

    return KonnektedKlass
  }
github Bandwidth / redux-facet / src / factories / createWithFacetData.js View on Github external
const selectorFactory = (dispatch, factoryOptions) => {
    return (state, ownProps) => {
      const facetState = selectors.createFacetStateSelector(
        ownProps.facetName || resolvedFacetName,
      )(state);
      return {
        ...ownProps,
        ...(resolvedMapStateToProps
          ? resolvedMapStateToProps(facetState, ownProps, state)
          : {}),
      };
    };
  };

  return connectAdvanced(selectorFactory, {
    methodName: 'withFacetData',
    shouldHandleStateChanges: true,
    getDisplayName: name => `WithFacetData[${resolvedFacetName}](${name})`,
  });
};
github esamattis / lean-redux / src / lean.js View on Github external
export function connectLean(options = plain) {
    return connectAdvanced(
        dispatch => {
            const scopedStateCache = createCache();
            const mappedStateCache = createCache({initial: null});
            const propsCache = createCache();
            const scopeCache = createCache();

            var initialState = null;
            var boundHandlers = null;
            var finalProps = null;
            var setStateCallbacks = [];
            const handlerContext = {};
            const handlers = pickFunctions(options);

            var mapState = typeof options.mapState === "function"
                ? options.mapState
                : state => {
github popcodeorg / popcode / src / higherOrderComponents / resizableFlex / index.js View on Github external
export default function resizableFlex(size) {
  if (!isFlexResizingSupported()) {
    return shamResizableFlex(size);
  }

  const instanceId = (nextInstanceId++).toString();
  const getResizableFlexGrow = makeGetResizableFlexGrow(instanceId);

  return connectAdvanced(
    dispatch => {
      const regions = times(size, () => ({current: null}));
      const initialMainSizes = times(size, constant(null));

      const stateIndependentFunctions = {
        isFlexResizingSupported: true,

        onResizableFlexDividerDrag(beforeIndex, event, payload) {
          const afterIndex = findIndex(regions, 'current', beforeIndex + 1);
          const [{current: before}, {current: after}] = at(regions, [
            beforeIndex,
            afterIndex,
          ]);

          const {getCurrentSize, getDesiredSize} = directionAdapterFor(before);
github Bandwidth / redux-facet / src / facet.js View on Github external
return {
        ...ownProps,
        ...(mapDispatchToProps
          ? mapDispatchToProps(facetDispatch, ownProps, dispatch)
          : {}),
        facetDispatch,
      };
    };
  };

  const providedProps = isFunction(facetName) ? {} : { facetName };

  return compose(
    withProps(providedProps),
    connectAdvanced(selectorFactory, {
      methodName: 'facet',
      shouldHandleStateChanges: false,
      getDisplayName: name => `Facet[${resolvedFacetName}](${name})`,
    }),
  );
};
github keybase / client / shared / util / __mocks__ / typed-connect.tsx View on Github external
const mockConnect = () => RR.connectAdvanced(selectorDelegatorFactory)
github davazp / lector / packages / lector-react-redux / lib / index.js View on Github external
function connectReaders(object) {
  return connectAdvanced(readerSelectorsFactory(object));
}