From 72028c798c727ca2c4fc9fb1eeb38073f8856df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Westk=C3=A4mper?= Date: Mon, 22 Jul 2024 16:14:27 +0300 Subject: [PATCH] Review feedback --- src/components/NostoProvider.tsx | 3 ++- src/components/helpers.ts | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 src/components/helpers.ts 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