A
A
Alexey Chernyshev2016-10-03 09:52:40
React
Alexey Chernyshev, 2016-10-03 09:52:40

How to dynamically load a react module into an application?

Friends, tell me how you can dynamically load react components while the site is running.

For example, we have a menu, and while clicking on one of the sections, load the js file with the react component and include it in the application.

This is necessary in order not to load extra js with components until it is required.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Antropov, 2016-10-03
@nanomen

If webpack is used to build the application, then you can simply use the require.ensure, System.import constructs. Pack itself processes them and cuts the code into separate chunks. You can see how you can separate individual routes here https://github.com/davezuko/react-redux-starter-ki...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question