N
N
Ninja Mate2016-05-04 12:06:18
JavaScript
Ninja Mate, 2016-05-04 12:06:18

How to make links to different module elements (Webpack, react-router)?

Application on ReactJS, I collect Webpack. Now a project divided into chunks in which each piece has its own file and its own link in the browser.
I want to split one of the modules so that the link looks like site/module/name. In other words, there is only one module, and different links lead to its parts.
Now

//reports/index.js
module.exports = function(location, cb) {
    if (typeof require.ensure == 'function') {
        /* Asynchronous loading of a component
        that is inside of require.ensure */
        require.ensure([], (require) => {
            cb(null, require('./Reports'))
        }, 'reports')
    } else {
        /* Server side synchronous loading */
        cb(null, require('./Reports'));
    }
}

//react-router
<Route  path="Reports" getComponent={
                                        (location,cb)=>require('./Reports/index')(location,cb)
                                        }> </Route>

//Reports.js сюда индекс отправляет, просто три кнопки, которые должны стать ссылками в браузере
<Button onClick={()=>this.searchENGReport()} block>ENGReport</Button>
<Button onClick={()=>this.searchNPSReport()} block>NPSReport</Button>
<Button onClick={()=>this.searchPSReport()} block>PSReport</Button>

How to change this?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question