{"version":3,"file":"NoSSR.mjs","names":[],"sources":["../../src/nossr/NoSSR.tsx"],"sourcesContent":["/**\n * Copyright (c) 2022-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { type ReactNode, useSyncExternalStore } from \"react\";\n\ninterface Props {\n  children: ReactNode;\n  fallback: ReactNode | null;\n}\n\n/**\n * A component that makes children not run on the server\n * Useful for not rendering private stuff on the server which will then be cached.\n */\nexport const NoSSR = ({ children, fallback = null }: Props): ReactNode => {\n  const mounted = useSyncExternalStore(\n    () => () => {},\n    () => typeof window !== \"undefined\",\n    () => false,\n  );\n\n  if (!mounted) {\n    return fallback;\n  }\n\n  return children;\n};\n"],"mappings":";;;;;;;;;;;;;AAmBA,MAAa,SAAS,EAAE,UAAU,WAAW,WAA6B;AAOxE,KAAI,CANY,iCACF,UACN,OAAO,WAAW,mBAClB,MACP,CAGC,QAAO;AAGT,QAAO"}