Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
});
});
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}
)
}
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}
)
}