couldn't make require.ensure to work
See original GitHub issueHi there,
I’m trying to use dynamic routing with require.ensure
but am unable to make it work. Here is my code snippet:
routes.js
import React from 'react';
import { Router, Route, browserHistory } from 'react-router';
import App from './App';
const componentRoutes = {
component: App,
path: '/',
childRoutes: [
{
path: 'Login',
getComponent: (a, cb) => require.ensure([], require => {cb(null, require('./Login'));})
},
{
path: 'Report',
getComponent: (a, cb) => require.ensure([], require => {cb(null, require('./Report'));})
}
]
};
const Routes = () => {
return (
<Router history={browserHistory} routes={componentRoutes} />
);
};
export default Routes;
There is neither error on the terminal nor on the Chrome’s console. The page just renders the App component.
Am I missing something?
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Writing tests for javascript module using webpack's require ...
I am running mocha tests on my server, testing source scripts an isolated unit test manner. One of the scripts I am testing...
Read more >Follow-up on still needing to use require.ensure #9076 - GitHub
Awhile back I created an issue trying to make a case for keeping around require.ensure , which I knew would get deprecated as...
Read more >When a USPS Text is not a USPS Text
What's smishing? A fraudulent text message pretending to be from a reputable source – your bank, for example, or the U.S. Postal Service....
Read more >Identity verification for Apple Card or Apple Cash
If your Apple Card application was declined because your identification information couldn't be verified, learn what you can do.
Read more >“We couldn't update system reserved partition” error installing ...
When upgrading to Windows 10, you may encounter the error “We couldn't update system reserved partition”, error code 0xc1900104, or error code 0x8000f0922....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For example
require('./Login')
looks suspicious because if you use ES6 exports there, you likely wantrequire('./Login').default
instead.It’s weird RR didn’t throw an error on this. (Which is why I wanted to isolate it—wasn’t sure if RR handles such errors.)