1.1.0 • Published 5 years ago

get-component-async v1.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

get-component-async

load component async for react router

Use

install by:

npm i -S get-component-async

For react router

import getComponentAsync from "get-component-async";

<HashRouter>
  <Route
    path="/sub"
    component={getComponentAsync(
      // webpack code split
      () => import("./sub")
    )}
  />
</HashRouter>;

./sub is code is:

export default class Sub extends Component {
  render() {
    return <div>sub</div>;
  }
}

For big component

import { getElementAsync } from "get-component-async";

<div>
  ...others
  {getElementAsync(() => import("./bigComponent"))}
</div>;

Show loading before loaded

import { getElementAsync } from "get-component-async";

<div>
  ...others
  {getElementAsync(() => import("./bigComponent"), <Loading />, props)}
</div>;

Set default loading before loaded

import { setDefaultLoading } from "get-component-async";

setDefaultLoading(<Loading />);
1.1.0

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago