Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getInitialProps = component => {
const { config } = this.props;
if (isFunction(component.getInitialProps)) {
component.getInitialProps(config).then(initialProps => this.setState({ initialProps }));
}
};
export const makeMapDispatchToProps = mapDispatchToProps => (
dispatch,
ownProps
) => {
if (!mapDispatchToProps) {
return {};
}
const wrappedDispatch = o(
dispatch,
mergeDeepRight({ meta: { namespace: ownProps.namespace } })
);
if (isFunction(mapDispatchToProps)) {
return mapDispatchToProps(wrappedDispatch, ownProps);
}
if (isObject(mapDispatchToProps)) {
const wrapActionCreator = actionCreator =>
compose(
wrappedDispatch,
actionCreator
);
return map(wrapActionCreator, mapDispatchToProps);
}
throw new TypeError('mapDispatchToProps is not an object or a function');
};
const mergeNamespace = curry((isForced, namespace, action) => {
if (!namespace) {
return action;
}
if (isFunction(action)) {
const nextAction = (...args) => action(...args);
if (isForced) {
nextAction.meta = { namespace };
} else {
nextAction.meta = { namespace: getNamespaceByAction(action) || namespace };
}
return nextAction;
}
if (isForced) {
return mergeDeepLeft({ meta: { namespace } }, action);
}
return mergeDeepRight({ meta: { namespace } }, action);
const handler = ({ props, reducers }) => {
invariant(
props.namespace || !isFunction(reducers),
'You can only inject reducers as functions if you specify a namespace.'
);
nextStore.replaceReducer(
composeReducers(reducer, combineReducerEntries(storeInterface.getEntries(nextStore)))
);
};
const WithProps = props => (
);
componentDidMount() {
const { initialProps } = this.state;
if (!initialProps) {
const { config } = this.props;
const { component } = config;
if (isFunction(component.preload)) {
return component.preload().then(this.getInitialProps);
}
this.getInitialProps(component);
}
}
const makeThunkMiddleware = dependencies => ({ dispatch, getState }) => next => action => {
if (isFunction(action)) {
const namespace = getNamespaceByAction(action);
return action({
dispatch: o(dispatch, defaultNamespace(namespace)),
getState,
getNamespacedState: feature => getStateByNamespace(feature, namespace, getState()),
namespace,
...dependencies,
});
}
return next(action);
};
return R.map(config => {
const proxyConfig = R_.isFunction(config) ? config() : config;
return proxyMiddleware(proxyConfig.context, proxyConfig);
}, normalizedConfig);
};
return map(config => {
const proxyConfig = isFunction(config) ? config() : config;
return httpProxyMiddleware(proxyConfig.context, proxyConfig);
}, normalizedConfig);
};