diff --git a/src/components/NostoProvider.tsx b/src/components/NostoProvider.tsx index 325b4f1..e9a2347 100644 --- a/src/components/NostoProvider.tsx +++ b/src/components/NostoProvider.tsx @@ -1,6 +1,7 @@ import React, { useEffect, isValidElement } from "react" import { NostoContext, RecommendationComponent } from "../context" import { NostoClient } from "../types" +import { isNostoLoaded } from "./helpers" /** * @group Components @@ -86,7 +87,7 @@ export default function NostoProvider(props: NostoProviderProps) { window.nostojs(api => api.setAutoLoad(false)) } - if (!window.nosto && !shopifyMarkets) { + if (!isNostoLoaded() && !shopifyMarkets) { const script = document.createElement("script") script.type = "text/javascript" script.src = "//" + (host || "connect.nosto.com") + "/include/" + account diff --git a/src/components/helpers.ts b/src/components/helpers.ts new file mode 100644 index 0000000..f3924ff --- /dev/null +++ b/src/components/helpers.ts @@ -0,0 +1,3 @@ +export function isNostoLoaded() { + return typeof window.nosto !== "undefined" +} \ No newline at end of file