本文作者：IMWeb 陈映平 原文出处：IMWeb社区 未经同意，禁止转载
It is frequently asked that how to load components on demand if you use
In the official readme, there is a recommended loader named react-router-proxy-loader that can fullfill this need.
However, it depends on
webpack and there are many cases where
webpack is not included in the build task.
In fact, it is quite easy to achieve the same goal without
webpack. Here is an example with little dependencies, and if you see
example/jsx/loader.js, you will find that it is nearly the same as
react-router-proxy-loader, except that you don't need to have
Checkout this repo by
git clone or download the ziped file.
git clone https://github.com/chyingp/react-router-load-on-demand.git
react-tools to compile
npm install -g react-tools
example folder via command line
jsx to compile jsx format file to normal js file.
jsx -w jsx js
Next start a mini server. (Thanks to https://gist.github.com/ryanflorence/701407)
Finally, visits it in browser http://localhost:8888/
You can see the beautiful page.
home.js was loaded at first view.
about component was shown.
Only at this time, the
about component was loaded on demand.