Skip to content

Commit

Permalink
#2912 refactor the root name
Browse files Browse the repository at this point in the history
  • Loading branch information
StarlaStarla committed Aug 3, 2023
1 parent 88e94e6 commit ed5b2b3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions packages/ketcher-react/src/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ function Editor(props: EditorProps) {
const ketcherInitEvent = new Event(KETCHER_INIT_EVENT_NAME);

useEffect(() => {
const rootRef = createRoot(rootElRef.current as HTMLDivElement);
const appRoot = createRoot(rootElRef.current as HTMLDivElement);
init({
...props,
element: rootElRef.current,
rootRef,
appRoot,
}).then((ketcher: Ketcher) => {
if (typeof onInit === 'function') {
onInit(ketcher);
window.dispatchEvent(ketcherInitEvent);
}
});
return () => rootRef.unmount();
return () => appRoot.unmount();
// TODO: provide the list of dependencies after implementing unsubscribe function
}, []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class KetcherBuilder {

async appendUiAsync(
element: HTMLDivElement | null,
rootRef: Root,
appRoot: Root,
staticResourcesUrl: string,
errorHandler: (message: string) => void,
buttons?: ButtonsConfig,
Expand All @@ -65,7 +65,7 @@ class KetcherBuilder {
const editor = await new Promise<Editor>((resolve) => {
initApp(
element,
rootRef,
appRoot,
staticResourcesUrl,
{
buttons: buttons || {},
Expand Down
6 changes: 3 additions & 3 deletions packages/ketcher-react/src/script/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { StructServiceProvider } from 'ketcher-core';

interface Config {
element: HTMLDivElement | null;
rootRef: Root;
appRoot: Root;
staticResourcesUrl: string;
structServiceProvider: StructServiceProvider;
buttons?: ButtonsConfig;
Expand All @@ -30,7 +30,7 @@ interface Config {

async function buildKetcherAsync({
element,
rootRef,
appRoot,
staticResourcesUrl,
structServiceProvider,
buttons,
Expand All @@ -42,7 +42,7 @@ async function buildKetcherAsync({
builder.appendServiceMode(structServiceProvider.mode);
await builder.appendUiAsync(
element,
rootRef,
appRoot,
staticResourcesUrl,
errorHandler,
buttons,
Expand Down
4 changes: 2 additions & 2 deletions packages/ketcher-react/src/script/ui/App/initApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { initMouseListener } from '../state/mouse';

function initApp(
element: HTMLDivElement | null,
root: Root,
appRoot: Root,
staticResourcesUrl: string,
options: any,
server: StructService,
Expand All @@ -42,7 +42,7 @@ function initApp(
store.dispatch(initMouseListener(element));
store.dispatch(initResize());

root.render(
appRoot.render(
<Provider store={store}>
<SettingsContext.Provider value={{ staticResourcesUrl }}>
<ErrorsContext.Provider value={{ errorHandler: options.errorHandler }}>
Expand Down

0 comments on commit ed5b2b3

Please sign in to comment.