ctrlplusb/react-async-component

Pre resolve an asyncComponent when another component resolves

georgehenderson opened this issue · 3 comments

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]
})

Or maybe more generic like:

asyncComponent({
  ...
  onResolve: () => AnotherAsyncComponent.resolve()
})

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

Is this functionality implemented by any mean??