Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behavior on server-side when using in conjunction with dynamic imports #27

Open
oyeanuj opened this issue Mar 31, 2018 · 7 comments
Open

Comments

@oyeanuj
Copy link

oyeanuj commented Mar 31, 2018

Hi @ctrlplusb, while debugging ctrlplusb/react-jobs#51 & ctrlplusb/react-jobs#56, I realized that if there were jobs on dynamic import components, then those jobs wouldn't execute on the server-side since the components are not being imported before render is considered complete.

Here is a simple summarized hierarchy that could reproduced it for me -

<App>
  <Auth> /* <--- Fetch data */
    <Switch>
      <Route component = { AsyncProfile } />
      { /* AsyncProfile dynamically imports Profile which fetches the data */ }
    </Switch>
  </Auth>
<App>

Looking through codebases of this library and react-jobs, it seems like this issue should be resolved here. Thoughts on what should be the expected behavior?

@oyeanuj oyeanuj changed the title Behavior when using in conjunction with dynamic imports Behavior on server-side when using in conjunction with dynamic imports Mar 31, 2018
@ctrlplusb
Copy link
Owner

Definitely should resolve. Sorry was half way through updating react-jobs. Will do and then post an example for you on how to interop the two. I'll probably link the example with react-async-bootstrapper - since that is the "standard" interop interface between the two.

@ctrlplusb
Copy link
Owner

Apologies @oyeanuj been so busy!

@oyeanuj
Copy link
Author

oyeanuj commented Apr 27, 2018

@ctrlplusb No worries, hope you get a chance soon :)

@oyeanuj
Copy link
Author

oyeanuj commented Jul 28, 2018

@ctrlplusb Just checking in for an update here? Not sure if you are done updating react-jobs, but an example would be super helpful since this prevents SSR with data-fetching right now :(

@ctrlplusb
Copy link
Owner

Hey @oyeanuj

You are the definition of patience. 😃

I am trying to throw up a razzle based example now, using react-async-component as well as react-jobs. 👍

@ctrlplusb
Copy link
Owner

Ok, got it working. :)

Demo: https://razzle-async-components-and-data.now.sh/

Source: https://github.com/ctrlplusb/demo-react-async-and-jobs

I also added emotion for good measure.

@oyeanuj
Copy link
Author

oyeanuj commented Dec 23, 2018

@ctrlplusb I've had a chance to drill down more into this and I have one quick question to ask, and observation to report:

Theoretically, should a setup like this work with react-jobs and react-async-bootstrapper on the server-side?

<App>
  <Auth> /* <--- Fetch data */
    <ListingPage> /* <--- Fetch data */
      <MovieOne /> /* <--- Fetch data */
      <MovieTwo /> /* <--- Fetch data */
  </Auth>
<App>

I'm noticing that the after the first pass of react-jobs, the asyncBootstrapper is considering its job over before rest of the jobs have a chance to resolve and render their children.

Any ideas or thoughts would be super useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants