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

Two same simultaneously async components #90

Open Magnielcz opened 5 years ago

Magnielcz commented 5 years ago

I have one async component which I'm using multiple times across application. One use case is, I'm rendering same component twice (with different props). But after resolving async component, only first component is re-rendered. Second one is stuck at loading phase. Let me show you, what I mean.

Simple ComponentAsync:

import { asyncComponent } from 'react-async-component';

export default asyncComponent({
    resolve: () => import( './Component'),
    LoadingComponent: () => <div>Loading component</div>
});`

Multiple using of async component:

import ComponentAsync from './ComponentAsync';

...

render()
{
   return (
      <ComponentAsync id={1} />
      <ComponentAsync id={2} />
    );
}

My first thought was, the problem is in needToResolveOnBrowser function. For first component returns true and component is continue to resolving module. For next one is returns false, even the async component is still unresolved. After a while, I think it's wanted behavier, but I'm missing the piece of code, where and what should cause re-render for my second async component after first component is resolved.

oyeanuj commented 5 years ago

@ctrlplusb @Magniel I have the same issue. I have an editor component being rendered async, and in pages where there are more than one of them, it intermittently doesn't load even though I can see the file loaded in the Network panel.

Any solutions/workarounds?

Magnielcz commented 5 years ago

@oyeanuj I switch to 'react-loadable'. It has advanced functionality, very similar syntax and renders multiple instances of async component at once correctly.

kivohin commented 5 years ago

We are having the exact same issue as @Magniel, is there any update on this @ctrlplusb?

thebugger2000 commented 4 years ago

Hey,

There's no other way to reach out you I guess. My name is Jim Ferguson. I'm working on a ionic/angular app. you made a post about web share last month. I was wondering if you have any suggestions for how to post a image to the share sheet or straight to the Instagram app on iOS to start a post for the user with my image attached?

you posted in:
https://github.com/Microsoft/TypeScript/issues/18642

I know this is out of the blue, but this has been killing me for over a week now.

Please reach out at your earliest convenience.

Thank you

Jim

Magnielcz commented 4 years ago

Hey,

There's no other way to reach out you I guess. My name is Jim Ferguson. I'm working on a ionic/angular app. you made a post about web share last month. I was wondering if you have any suggestions for how to post a image to the share sheet or straight to the Instagram app on iOS to start a post for the user with my image attached?

you posted in: microsoft/TypeScript#18642

I know this is out of the blue, but this has been killing me for over a week now.

Please reach out at your earliest convenience.

Thank you

Jim

Hi, I used Web Share on Android platform for sharing recorded video. Last time I was digging into Web Share API, Safari on iOS did not support Web Share level 2 (= file share), so I'm sorry, I don't think it is possible at this moment.