diff --git a/demo/tiddlers/docs/useRenderTiddler.tid b/demo/tiddlers/docs/useRenderTiddler.tid
index fb2a873..f981c9e 100644
--- a/demo/tiddlers/docs/useRenderTiddler.tid
+++ b/demo/tiddlers/docs/useRenderTiddler.tid
@@ -21,9 +21,9 @@ import { IDefaultWidgetProps, ParentWidgetContext } from '$:/plugins/linonetwo/t
...
return (
-
+
-
+
);
```
diff --git a/src/hooks/useRenderTiddler.ts b/src/hooks/useRenderTiddler.ts
index 824c485..531208a 100644
--- a/src/hooks/useRenderTiddler.ts
+++ b/src/hooks/useRenderTiddler.ts
@@ -15,7 +15,7 @@ export function useRenderTiddler(tiddlerTitle: string, containerReference: RefOb
}
if (parentWidget === undefined) {
throw new Error(
- 'Your plugin have a bug: `parentWidget` is undefined, you should use ``, see tw-react for document.',
+ 'Your plugin have a bug: `parentWidget` is undefined, you should use ``, see tw-react for document.',
);
}
if (options?.skip === true) {
diff --git a/src/hooks/useWidget.ts b/src/hooks/useWidget.ts
index 94d1acc..ef7fbe8 100644
--- a/src/hooks/useWidget.ts
+++ b/src/hooks/useWidget.ts
@@ -16,7 +16,7 @@ export function useWidget(parseTreeNode: IParseTreeNode, containerReference: Ref
}
if (parentWidget === undefined) {
throw new Error(
- 'Your plugin have a bug: `parentWidget` is undefined, you should use ``, see tw-react for document.',
+ 'Your plugin have a bug: `parentWidget` is undefined, you should use ``, see tw-react for document.',
);
}
if (options?.skip === true) {
diff --git a/src/widget.ts b/src/widget.ts
index 08771e6..926879f 100644
--- a/src/widget.ts
+++ b/src/widget.ts
@@ -16,11 +16,6 @@ if (typeof window !== 'undefined') {
global.React = React;
}
-// DEBUG: console ReactDom
-console.log(`ReactDom`, ReactDom);
-// DEBUG: console ReactDomClient
-console.log(`ReactDomClient`, ReactDomClient);
-
class ReactWidgetImpl<
IProps extends ITWReactProps = ITWReactPropsDefault,
> extends Widget implements IReactWidget {
@@ -99,7 +94,7 @@ class ReactWidgetImpl<
if (this.reactComponent === undefined || this.reactComponent === null) {
return;
}
- if (this.root === undefined) {
+ if (this.root === undefined && this.parentDomNode !== undefined) {
const nextSibling = this.findNextSiblingDomNode();
this.render(this.parentDomNode, nextSibling);
return;
@@ -111,7 +106,7 @@ class ReactWidgetImpl<
currentProps.parentWidget = this;
}
const reactElement = React.createElement(this.reactComponent, currentProps);
- this.root.render(reactElement);
+ this.root?.render?.(reactElement);
}
destroy() {