-
-
Save rubenspgcavalcante/28cad55347f89372304e927a9c08516d to your computer and use it in GitHub Desktop.
Wrapping up in a lazy component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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