From 05243f2bbf305fdd025386e77fbfd5d3adbd169c Mon Sep 17 00:00:00 2001 From: Nicholas Chiang Date: Wed, 9 Aug 2023 16:59:20 -0600 Subject: [PATCH] fix(components/useGeographies): allow SSR with JSON This patch updates the `useGeographies` hook to allow server-side rendering when passing in a static JS object (e.g. from a local JSON file). This hook will still prevent trying to fetch external geography data when rendering server-side. --- src/components/useGeographies.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/useGeographies.js b/src/components/useGeographies.js index 9781b34..1a28045 100644 --- a/src/components/useGeographies.js +++ b/src/components/useGeographies.js @@ -15,11 +15,9 @@ export default function useGeographies({ geography, parseGeographies }) { const [output, setOutput] = useState({}) useEffect(() => { - if (typeof window === `undefined`) return - if (!geography) return - if (isString(geography)) { + if (isString(geography) && typeof window !== `undefined`) { fetchGeographies(geography).then((geos) => { if (geos) { setOutput({