diff --git a/CustomView.ts b/CustomView.ts index 97bf201..4dd4d23 100644 --- a/CustomView.ts +++ b/CustomView.ts @@ -2,10 +2,15 @@ import { ItemView, WorkspaceLeaf } from "obsidian"; // Each view is uniquely identified by a text string // and several operations require that you specify the view you'd like to use. // Extracting it to a constant, VIEW_TYPE_EXAMPLE, is a good idea—as you will see later in this guide. +import { Root, createRoot } from "react-dom/client"; +import * as React from "react"; +import { ExampleReactView } from "./ReactView"; export const VIEW_TYPE_EXAMPLE = "example-view"; export class ExampleView extends ItemView { + root: Root | null = null; + constructor(leaf: WorkspaceLeaf) { super(leaf); } @@ -19,12 +24,17 @@ export class ExampleView extends ItemView { } async onOpen() { - const container = this.containerEl.children[1]; - container.empty(); - container.createEl("h4", { text: "Example view" }); + // const container = this.containerEl.children[1]; + // container.empty(); + // container.createEl("h4", { text: "Example view" }); + this.root = createRoot(this.containerEl.children[1]); + // this.root.render(
This is a React view
+