Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 })
)
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),
);
};
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)
}
}
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;