Update hello_world_plugin.mdx (#222562)

Update hello_world_plugin - plugin.tsx file
This commit is contained in:
Ola Pawlus 2025-06-04 16:40:21 +02:00 committed by GitHub
parent 11247fe50b
commit 9ef486f4eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -91,18 +91,30 @@ And add the following to it:
import React from 'react';
import ReactDOM from 'react-dom';
import { AppMountParameters, CoreSetup, CoreStart, Plugin } from '@kbn/core/public';
import { DeveloperExamplesSetup } from '@kbn/developer-examples-plugin/public';
export class HelloWorldPlugin implements Plugin {
public setup(core: CoreSetup) {
interface SetupDeps {
developerExamples: DeveloperExamplesSetup;
}
export class HelloWorldPlugin implements Plugin<void, void, SetupDeps> {
public setup(core: CoreSetup, deps: SetupDeps) {
// Register an application into the side navigation menu
core.application.register({
id: 'helloWorld',
title: 'Hello World',
async mount({ element }: AppMountParameters) {
ReactDOM.render(<div>Hello World!</div>, element);
ReactDOM.render(<div data-test-subj="helloWorldDiv">Hello World!</div>, element);
return () => ReactDOM.unmountComponentAtNode(element);
},
});
// This section is only needed to get this example plugin to show up in our Developer Examples.
deps.developerExamples.register({
appId: 'helloWorld',
title: 'Hello World Application',
description: `Build a plugin that registers an application that simply says "Hello World"`,
});
}
public start(core: CoreStart) {
return {};