Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: staylor/react-helmet-async
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9c1cc27d04e508ee28b026094caf6181316262c1
Choose a base ref
...
head repository: staylor/react-helmet-async
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b903f505f502cf165ec20ccd8f24ba01df14eafe
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Nov 21, 2023

  1. Copy the full SHA
    b903f50 View commit details
Showing with 11 additions and 7 deletions.
  1. +1 −1 package.json
  2. +7 −1 src/HelmetData.ts
  3. +3 −5 src/Provider.tsx
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-helmet-async",
"version": "2.0.0",
"version": "2.0.1",
"description": "Thread-safe Helmet for React 16+ and friends",
"sideEffects": false,
"main": "./lib/index.js",
8 changes: 7 additions & 1 deletion src/HelmetData.ts
Original file line number Diff line number Diff line change
@@ -17,9 +17,15 @@ interface HelmetDataContext {
helmet: HelmetServerState;
}

export const isDocument = !!(
typeof window !== 'undefined' &&
window.document &&
window.document.createElement
);

export default class HelmetData implements HelmetDataType {
instances = [];
canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
canUseDOM = isDocument;
context: HelmetDataContext;

value = {
8 changes: 3 additions & 5 deletions src/Provider.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import type { PropsWithChildren } from 'react';
import React, { Component } from 'react';

import HelmetData from './HelmetData';
import HelmetData, { isDocument } from './HelmetData';
import type { HelmetServerState } from './types';

const defaultValue = {};

export const Context = React.createContext(defaultValue);

interface ProviderProps {
context: {
context?: {
helmet: HelmetServerState;
};
}

const canUseDOM = typeof document !== 'undefined';

export default class HelmetProvider extends Component<PropsWithChildren<ProviderProps>> {
static canUseDOM = canUseDOM;
static canUseDOM = isDocument;

helmetData: HelmetData;