M
M
Maxim Ivanov2017-06-26 14:12:17
JavaScript
Maxim Ivanov, 2017-06-26 14:12:17

Is it possible to dynamically load components in ReactJS without knowing about them when building the application itself (as it is implemented in Angular 2+)?

Hello everyone, please help me solve the problem, although help in the search.
There is a task:
* developers develop components (assume on react)
* then they put the compiled component in the dist directory
* indicate in the database that there is such and such a component
* after that, when the application is initialized in the browser
* asks the server which components it displays and loads asynchronously anything-1.component.js, .. N
* and easily renders all components and binds data
I myself did not write anything in React (only helloWorld wrote once), I write mainly in Angular
But after the first ng, I realized that they overdid it. In order to dynamically load components there, so that a component factory with its templates is created, you need to specify entryComponents for the root module, but here the problem is that you need to specify all the components that you want to dynamically display, and if I'm in the browser I don’t know which ones, it turns out I specify (all my 10 thousand components for entryComponents as links), well, this is a stupid decision, besides, if I develop a new component, I will have to rebuild my application (via webpack or something) .
What does not suit me is that I have to specify all the components that I have, and this is implemented in Angular, Carl ... The first Angular was written in pure javascript, but everything is global there, at any time, I could load my script asynchronously (which would be an Angular controller with templates) and it all worked for me if I connected a new controller to angular.module, and now it’s like this only when building.

@NgModule({
  imports: [...],
  declarations: [...],
  entryComponents: [
    Anything1Component,
    ...,
    AnythingNComponent
  ],
  bootstrap: [ AppComponent ]
})
export class AppModule { }

Tell me if React can load components, or some other frameworks so that you don’t have to worry about such things that are present in Angular, because Angular is generated by me from TypeScript using Webpack and there is such a mess in the compiled code that you don’t even know how write your own wrapper.
There would be more possibilities in pure javascript (at least write in jQuery), but the problem is readability and distribution for other developers, but you want simple data-binding and other convenient OOP in conjunction with your web application.
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
davidnum95, 2017-06-26
@splincodewd

google react async load components

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question