Skip to content

Switch to contentEl #181

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions en/Plugins/Getting started/Use React in your plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const ReactView = () => {

## Mount the React component

To use the React component, it needs to be mounted on a [[HTML elements]]. The following example mounts the `ReactView` component on the `this.containerEl.children[1]` element:
To use the React component, it needs to be mounted on a [[HTML elements]]. The following example mounts the `ReactView` component on the `this.contentEl` element:

```tsx
import { StrictMode } from 'react';
Expand All @@ -68,7 +68,7 @@ class ExampleView extends ItemView {
}

async onOpen() {
this.root = createRoot(this.containerEl.children[1]);
this.root = createRoot(this.contentEl);
this.root.render(
<StrictMode>
<ReactView />,
Expand Down Expand Up @@ -104,7 +104,7 @@ Another alternative is to create a React context for the app to make it globally
2. Wrap the `ReactView` with a context provider and pass the app as the value.

```tsx title="view.tsx"
this.root = createRoot(this.containerEl.children[1]);
this.root = createRoot(this.contentEl);
this.root.render(
<AppContext.Provider value={this.app}>
<ReactView />
Expand Down
2 changes: 1 addition & 1 deletion en/Plugins/User interface/Views.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class ExampleView extends ItemView {
}

async onOpen() {
const container = this.containerEl.children[1];
const container = this.contentEl;
container.empty();
container.createEl('h4', { text: 'Example view' });
}
Expand Down