erikras / react-redux-universal-hot-example

A starter boilerplate for a universal webapp using express, react, redux, webpack, and react-transform
MIT License
12k stars 2.5k forks source link

Has anyone ever tried to use "require.ensure' in this project? #1250

Open jboonmee opened 8 years ago

jboonmee commented 8 years ago

I've tried to get this (https://github.com/reactjs/react-router/issues/3232 ) to work, but without success. I ran into the following problems.

One curious thing though, when I used the AMD version of require (require([], cb) instead of require.ensure([], cb)), webpack did generated the chunk for the split point. But the routes still didn't work.

Any thoughts?

mdenisov commented 7 years ago

@jboonmee for require.ensure ([], cb)), you must activate the patch_require: true in webpack-isomorphic-tools.js file and wrap render in client.js:

import { Router, browserHistory, match } from 'react-router';

***

match({ routes: getRoutes(store), history }, (error, redirectLocation, renderProps) => {
    ReactDOM.render(
        <Provider store={ store } key="provider">
            <Router
                { ...renderProps }
                render={ props =>
                    <ReduxAsyncConnect { ...props } helpers={ { client } } filter={ item => !item.deferred } />
                }
            >
                { getRoutes(store) }
            </Router>
        </Provider>,
        dest
    );
});