https://github.com/gwuhaolin/get-component-async
react component load for webpack async code split
https://github.com/gwuhaolin/get-component-async
code-splitting webpack
Last synced: 11 months ago
JSON representation
react component load for webpack async code split
- Host: GitHub
- URL: https://github.com/gwuhaolin/get-component-async
- Owner: gwuhaolin
- Created: 2017-12-29T08:21:25.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-02T08:50:50.000Z (about 7 years ago)
- Last Synced: 2025-02-09T22:30:50.628Z (about 1 year ago)
- Topics: code-splitting, webpack
- Language: TypeScript
- Homepage:
- Size: 7.81 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# get-component-async
load component async for react router
## Use
install by:
```bash
npm i -S get-component-async
```
#### For react router
```jsx harmony
import getComponentAsync from "get-component-async";
import("./sub")
)}
/>
;
```
`./sub` is code is:
```jsx harmony
export default class Sub extends Component {
render() {
return
sub;
}
}
```
#### For big component
```jsx harmony
import { getElementAsync } from "get-component-async";
...others
{getElementAsync(() => import("./bigComponent"))}
;
```
#### Show loading before loaded
```jsx harmony
import { getElementAsync } from "get-component-async";
...others
{getElementAsync(() => import("./bigComponent"), , props)}
;
```
#### Set default loading before loaded
```jsx harmony
import { setDefaultLoading } from "get-component-async";
setDefaultLoading();
```