Skip to content

Commit bc24ea4

Browse files
committed
docs: Add wrapper div to react's createShadowRootUi example
Related to #456.
1 parent 86d0c9b commit bc24ea4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

docs/guide/content-script-ui.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,12 @@ export default defineContentScript({
253253
name: 'example-ui',
254254
position: 'inline',
255255
onMount: (container) => {
256+
// Container is a body, and React warns when creating a root on the body, so create a wrapper div
257+
const app = document.createElement('div');
258+
container.append(app);
259+
256260
// Create a root on the UI container and render a component
257-
const root = ReactDOM.createRoot(container);
261+
const root = ReactDOM.createRoot(app);
258262
root.render(<App />);
259263
return root;
260264
},

0 commit comments

Comments
 (0)