-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: restore async behaviour, fixes #141
- Loading branch information
Showing
11 changed files
with
65 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,41 @@ | ||
import * as React from 'react'; | ||
import {Component} from 'react'; | ||
import {GHCorner} from 'react-gh-corner'; | ||
import {AppWrapper} from './styled'; | ||
export interface AppState { | ||
|
||
import * as React from "react"; | ||
|
||
import imported, {lazy, LazyBoundary} from "../src"; | ||
|
||
const deferImport = (promise: Promise<any>) => new Promise(resolve => setTimeout(() => resolve(promise), 2000)); | ||
|
||
const Lazy = () => <div>I AM LAZY</div>; | ||
|
||
|
||
const ReactLazy = React.lazy(() => deferImport({default: Lazy})); | ||
const ImportedLazy = lazy(() => deferImport({default: Lazy})); | ||
const Imported = imported(() => deferImport({default: Lazy})); | ||
const ImportedLoading = imported(() => deferImport({default: Lazy}), { LoadingComponent: () => "imported is loading"}); | ||
|
||
function App() { | ||
return ( | ||
<div className="App"> | ||
<h1>Lazy Loading</h1> | ||
<ul> | ||
<li> | ||
<React.Suspense fallback={<div>Loading (React)</div>}> | ||
<ReactLazy/> | ||
</React.Suspense> | ||
</li> | ||
<li> | ||
<LazyBoundary fallback={<div>Loading (Imported)</div>}> | ||
<ImportedLazy/> | ||
</LazyBoundary> | ||
</li> | ||
<li> | ||
<Imported/> | ||
</li> | ||
<li> | ||
<ImportedLoading/> | ||
</li> | ||
</ul> | ||
</div> | ||
); | ||
} | ||
const repoUrl = 'https://github.com/zzarcon/'; | ||
export default class App extends Component <{}, AppState> { | ||
state: AppState = { | ||
|
||
} | ||
|
||
render() { | ||
return ( | ||
<AppWrapper> | ||
<GHCorner openInNewTab href={repoUrl} /> | ||
Example! | ||
</AppWrapper> | ||
) | ||
} | ||
} | ||
export default App; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {markMeta} from "./loadable"; | ||
|
||
export const loadByChunkname = (chunkName: string) => ( | ||
Promise.all( | ||
markMeta | ||
.filter(meta => meta.chunkName === chunkName) | ||
.map(meta => meta.loadable.load()) | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters