Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow plugin apps to use React on top level #16819

Closed
timroes opened this issue Feb 20, 2018 · 1 comment
Closed

Allow plugin apps to use React on top level #16819

timroes opened this issue Feb 20, 2018 · 1 comment
Labels
enhancement New value added to drive a business result Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@timroes
Copy link
Contributor

timroes commented Feb 20, 2018

Currently the whole app infrastructure within plugins is tightly coupled with Angular. It's not "easily" possible to create an app within a plugin, that uses React at the top level. The easiest way I currently found is:

uiModules.get('kibana/myComponent', [])
  .component('myComponent', {
    controller: ($element) => {
      ReactDOM.render(
        <MyComponent />,
        $element[0]
      );
    }
  });

uiRoutes.enable();
uiRoutes.when('/', {
  template: '<my-component></my-component>',
  reloadOnSearch: false,
});

If you don't use the uiRoutes.enable (e.g. by just using chrome.setRootTemplate), you will

(a) have to somehow wait for Angular to boot up and the next digest cycle for the chrome to actually render the template, which can easily lead to ugly code like:

uiModules.get('kibana')
.run($timeout => $timeout(() => { /* mount react here */ }));

(b) as long as you don't use uiRoutes not all services will work as expected, since some setup work will be done via the uiRoutes.addSetupWorks methods. All those services (e.g. timefilter) would need manual setup work when not using the Angular routing.

I think we should have a high level API, like chrome.setRootComponent(<MyComponent />) to mount React components and still have all the services that an application might need in tact, unless they are all able to work without Angular.

@timroes timroes added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc triage_needed release_note:enhancement labels Feb 20, 2018
@epixa epixa added enhancement New value added to drive a business result and removed release_note:enhancement labels May 7, 2018
@epixa
Copy link
Contributor

epixa commented May 7, 2018

This is a non-issue in the new platform, and we don't plan to change this in the legacy core, so I'm going to close this out.

Follow along on #16253

@epixa epixa closed this as completed May 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
Development

No branches or pull requests

3 participants