Skip to content

Instantly share code, notes, and snippets.

@rubenspgcavalcante
Created November 16, 2018 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubenspgcavalcante/3294b7aca5bfb3a67175d5ff61b82ab5 to your computer and use it in GitHub Desktop.
Save rubenspgcavalcante/3294b7aca5bfb3a67175d5ff61b82ab5 to your computer and use it in GitHub Desktop.
Using React.lazy to return a lazy container
import React from "react";
import { connect } from "react-redux";
export default (mapStateToProps, dispatchMappingPromise, ...rest) => Component =>
React.lazy(() =>
dispatchMappingPromise.then(mapDispatchToProps => ({
default: connect(
mapStateToProps,
mapDispatchToProps,
...rest
)(Component)
}))
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment