(refactor): separate browser ready builds

This commit is contained in:
ManishMadan2882
2024-11-23 02:29:27 +05:30
parent 1595e0210a
commit dae0942d03
6 changed files with 34 additions and 41 deletions

View File

@@ -1,25 +1,7 @@
//development
import { createRoot } from "react-dom/client";
import { App } from "./App";
import { DocsGPTWidget } from './components/DocsGPTWidget';
import { SearchBar } from './components/SearchBar';
import React from "react";
if (typeof window !== 'undefined') {
const renderWidget = (elementId: string, props = {}) => {
const root = createRoot(document.getElementById(elementId) as HTMLElement);
root.render(<DocsGPTWidget {...props} />);
};
const renderSearchBar = (elementId: string, props = {}) => {
const root = createRoot(document.getElementById(elementId) as HTMLElement);
root.render(<SearchBar {...props} />);
};
(window as any).renderDocsGPTWidget = renderWidget;
(window as any).renderSearchBar = renderSearchBar;
}
const container = document.getElementById("app") as HTMLElement;
const root = createRoot(container)
root.render(<App />);
export { DocsGPTWidget };
export { SearchBar }
root.render(<App />);