Comments (1)
3.2 借助 react-loadable 轻松实现动态导入(dynamic imports)
import React from 'react';
import {render} from 'react-dom';
import {Provider} from 'react-redux';
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
import configureStore from './configureStore';
import Loadable from 'react-loadable';
const A = Loadable({
loader: () => import('./containers/A'),
loading: () => null,
});
const B = Loadable({
loader: () => import('./containers/B'),
loading: () => null,
});
const store = configureStore();
render(
<div>
<Provider store={store}>
<Router>
<div className="app-router-wrap">
<Route exact path="/" component={A}/>
<Route exact path="/realtime" component={A}/>
<Route path="/retention" component={B}/>
</div>
</Router>
</Provider>
</div>
, document.getElementById('root')
);
关于 Loadable 组件,参数中的 “loading” 属性为必选项,如果确实不想使用改属性,loading: () => null
即可。
参考
CRA with React Router v4 and react-loadable. Free code splitting
from cheungseol.github.io.
Related Issues (20)
- Webpack in Action (3)
- [Node]-util.promisify
- [Node] 错误优先回调
- [React] version 16 Error Handling
- Webpack in Action (4)
- 脚本ssh登录
- [Git]删除所有不在远程仓库维护的分支
- [WebGL] (1)
- callback && promise && async/await
- [React] React Hooks 中使用 setTimeout HOT 1
- Protobuf.js 解析 int64
- AbortController 使用总结
- CommonJS、CMD、AMD 模块规范
- 使用 dataloader 优化 GraphQL 性能
- Deno 实战
- 相交检测
- 浏览器重绘重排
- 《代码精进之路 从码农到工匠》
- Webpack in Action (1) DLL HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cheungseol.github.io.