Skip to content

Instantly share code, notes, and snippets.

@rubenspgcavalcante
Last active November 16, 2018 15:00
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/28cad55347f89372304e927a9c08516d to your computer and use it in GitHub Desktop.
Save rubenspgcavalcante/28cad55347f89372304e927a9c08516d to your computer and use it in GitHub Desktop.
Wrapping up in a lazy component
import React, { Suspense } from "react";
import LoadingIndicator from "./LoadingIndicator";
import PostEditor from "../PostEditor";
import lazyConnect from "./lazyConnect";
export default ({ platform, ...otherProps }) => {
const mapStateToProps = ({ posts: { currentPost } }) => ({ currentPost });
// Map all the named exports to dispatch
const mapDispatchToPropsPromise = import(`./actions/${platform}/post`);
const LazyContainer = lazyConnect(mapStateToProps, mapDispatchToPropsPromise)(PostEditor);
return (
<Suspense fallback={LoadingIndicator}>
<LazyContainer {...otherProps} />
</Suspense>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment