async-react-component
    TypeScript icon, indicating that this package has built-in type declarations

    0.7.0 • Public • Published

    npm-version license bower-license

    async-react-component

    Async component loaded based webpack 3 for react-router 4.

    Install

    It is recommended to run webpack on node 6.x or higher.

    Install the pkg with npm:

    npm install async-react-component --save
    

    or yarn

    yarn add async-react-component
    

    or bower

    bower install async-react-component
    

    Usage

    For react-router 4:

    import {BrowserRouter as Router, Route, Switch} from 'react-router-dom';
    import {getAsyncComponent} from 'async-react-component';
    
    // code splitting in webpack 3: https://webpack.js.org/guides/code-splitting/#dynamic-imports
    const App = () => import(/* webpackChunkName: "main" */ '../general/app/index');
    const Info = () => import(/* webpackChunkName: "info" */ '@components/info/index');
    
    const RootApp = () => {
        return (
            <Router>
                <Switch>
                    <Route exact path='/' component={getAsyncComponent(App)}></Route>
                    <Route path='/info' component={getAsyncComponent(Info)}></Route>
                    <Route render={() => <div>404 not found</div>}></Route>
                </Switch>
            </Router>
        );
    };
    
    ReactDOM.render(
        RootApp,
        document.getElementById('app')
    );
    

    License

    MIT

    Install

    npm i async-react-component

    DownloadsWeekly Downloads

    85

    Version

    0.7.0

    License

    MIT

    Last publish

    Collaborators

    • dwqs