ctrlplusb / react-async-component

Resolve components asynchronously, with support for code splitting and advanced server side rendering use cases.
MIT License
1.45k stars 62 forks source link

Pre resolve an asyncComponent when another component resolves #43

Open georgehenderson opened 7 years ago

georgehenderson commented 7 years ago

Thanks for building this package, it was simple to implement. I'm looking for suggestions on the best way to resolve an async component from another async component. I basically want to preload another component path after another resolves. This is just an optimization to remove the loading on a path users are likely to take next. Since they are just components, I guess I could pre initialize the next component in componentDidMount of the resolved component. Any other ideas?

It might be nice to have a built in mechanism for this like:

asyncComponent({
  ...
  thenResolve: [AnotherAsyncComp, AnotherAsyncComp2]
})
georgehenderson commented 7 years ago

Or maybe more generic like:

asyncComponent({
  ...
  onResolve: () => AnotherAsyncComponent.resolve()
})
theodesp commented 5 years ago

This would be a great feature as currently I would like to avoid using onLoading

tarun7886 commented 3 years ago

Is this functionality implemented by any mean??