-
Notifications
You must be signed in to change notification settings - Fork 24
Closed
Description
Thanks for all the nice libraries :)
I am finding it hard to make this react-async-component work with react-jobs. The following scenario does not work. Looks like it doesn't resolve the dynamic import before rendering. I use react-async-bootstrapper to do server-side rendering as described in the README.
/* Location of file "src/Home.jsx" */
const Home = props => (
<div>
I am home HomePage
</div>
);
/**
* Uses react-async-component
* Location of file "src/AsyncHomePage.jsx"
*/
const AsyncHomePage = asyncComponent({
resolve: () => import('./Home')
});
/**
* Uses react-jobs
* Component responsible for running all the jobs before rendering
* Location of file "src/DependencyResolver.jsx"
*/
const DependencyResolver = withJob({
LoadingComponent: () => <Loader />,
ErrorComponent: () => <GenericError />,
work: ({
dependencies = [],
dispatch
}) => Promise.all(
dependencies.map(
dependency => dispatch(dependency())
)
)
})(AsyncHomePage);AsyncHomePage is not rendered in the above scenario. Looks like the dynamic-import is not resolved on the server-side.
Having said that, the following works when I change the order.
/* Location of file "src/Home.jsx" */
const Home = props => (
<div>
I am home HomePage
</div>
);
/**
* Uses react-jobs
* Component responsible for running all the jobs before rendering
* Location of file "src/DependencyResolver.jsx"
*/
const DependencyResolver = withJob({
LoadingComponent: () => <Loader />,
ErrorComponent: () => <GenericError />,
work: ({
dependencies = [],
dispatch
}) => Promise.all(
dependencies.map(
dependency => dispatch(dependency())
)
)
})(Home); // <== Replaced './AsyncHomePage'
/**
* Uses react-async-component
* Location of file "src/AsyncHomePage.jsx"
*/
const AsyncHomePage = asyncComponent({
resolve: () => import('./DependencyResolver') // <== Replaced './Home'
});Now instead of passing AsyncHomePage to the DependencyResolver, I am passing the normal component and dynamically import the DependencyResolver
Metadata
Metadata
Assignees
Labels
No labels