D
D
danil_linkins2019-12-16 16:10:50
JavaScript
danil_linkins, 2019-12-16 16:10:50

React. Lazy loading component only when using it?

Right now my application has asynchronous loading of components (using react-router).
But one way or another, all components are loaded, even if they are not used.
How can I make it so that the component is loaded only when it is used (If the user goes to a certain route)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Robur, 2019-12-16
@Robur

https://reactjs.org/docs/code-splitting.html here everything is chewed in the most detailed way. It's hard to tell more

B
Boris Cherepanov, 2019-12-16
@xakplant

There is an example with react-router.
For example, the site works https://tools.xakplant.ru/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question