Skip to content

Two same simultaneously async components #90

Open
@Magnielcz

Description

@Magnielcz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions