question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

couldn't make require.ensure to work

See original GitHub issue

Hi 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:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
gaearoncommented, Jan 12, 2017

For example require('./Login') looks suspicious because if you use ES6 exports there, you likely want require('./Login').default instead.

1reaction
gaearoncommented, Jan 12, 2017

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.)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found