How to use the react-helmet.Helmet.canUseDOM function in react-helmet

To help you get started, we’ve selected a few react-helmet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozilla / addons-frontend / tests / server / amo / TestDetailsPage.js View on Github external
before(() => {
    // Tell helmet to run as if it's a server render.
    // This is caused by the jsdom env.
    Helmet.canUseDOM = false;
    return runTestServer({ app: 'amo' })
      .then((server) => {
        app = server;
      });
  });
github frontarm / navi / packages / react-navi-helmet / src / index.tsx View on Github external
export function HelmetProvider({
  canUseDOM,
  context,
  children,
}: HelmetProviderProps): React.ReactElement {
  // react-helmet thinks it's in a browser because of JSDOM, so we need to
  // manually let it know that we're doing static rendering.
  if (canUseDOM !== undefined) {
    Helmet.canUseDOM = canUseDOM
  }

  if (context && !Helmet.canUseDOM) {
    context.getHelmet = () => {
      return Helmet.renderStatic()
    }
  }

  return (
    
      {children}
    
  )
}
github frontarm / navi / packages / react-navi-helmet / src / index.tsx View on Github external
export function HelmetProvider({
  canUseDOM,
  context,
  children,
}: HelmetProviderProps): React.ReactElement {
  // react-helmet thinks it's in a browser because of JSDOM, so we need to
  // manually let it know that we're doing static rendering.
  if (canUseDOM !== undefined) {
    Helmet.canUseDOM = canUseDOM
  }

  if (context && !Helmet.canUseDOM) {
    context.getHelmet = () => {
      return Helmet.renderStatic()
    }
  }

  return (
    
      {children}
    
  )
}