Skip to content

Commit

Permalink
fix: Fix shadow dom in react versions below 18
Browse files Browse the repository at this point in the history
  • Loading branch information
tjtanjin committed Sep 29, 2024
1 parent 469bfda commit 40464be
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/context/ChatBotProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,21 @@ const ChatBotProvider = ({

const renderChildren = () => (
<div style={{ fontFamily: botSettings.general?.fontFamily }}>
<ChatBotContext.Provider value={{ loadConfig }}>
<SettingsProvider settings={botSettings} setSettings={setBotSettings}>
<StylesProvider styles={botStyles} setStyles={setBotStyles}>
<ToastsProvider>
<BotRefsProvider botIdRef={botIdRef} flowRef={botFlowRef}>
<PathsProvider>
<BotStatesProvider settings={botSettings}>
<MessagesProvider>{children}</MessagesProvider>
</BotStatesProvider>
</PathsProvider>
</BotRefsProvider>
</ToastsProvider>
</StylesProvider>
</SettingsProvider>
</ChatBotContext.Provider>
<ChatBotContext.Provider value={{ loadConfig }}>
<SettingsProvider settings={botSettings} setSettings={setBotSettings}>
<StylesProvider styles={botStyles} setStyles={setBotStyles}>
<ToastsProvider>
<BotRefsProvider botIdRef={botIdRef} flowRef={botFlowRef}>
<PathsProvider>
<BotStatesProvider settings={botSettings}>
<MessagesProvider>{children}</MessagesProvider>
</BotStatesProvider>
</PathsProvider>
</BotRefsProvider>
</ToastsProvider>
</StylesProvider>
</SettingsProvider>
</ChatBotContext.Provider>
</div>
);

Expand Down Expand Up @@ -135,8 +135,7 @@ const ChatBotProvider = ({
import("react-dom").then(({ render }) => {
render(renderChildren(), shadowRoot);
});
}
);
});
}, [isDomLoaded, botSettings, botStyles, children]);

if (!isDomLoaded) {
Expand Down

0 comments on commit 40464be

Please sign in to comment.