Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING: Update react-helmet-async to v2 #1045

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/govuk-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"plop": "3.1.2",
"react": "16.14.0",
"react-dom": "16.14.0",
"react-helmet-async": "1.3.0",
"react-helmet-async": "2.0.5",
"react-router": "5.3.4",
"react-router-dom": "5.3.4",
"serverless": "3.39.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/govuk-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"plop": "3.1.2",
"react": "16.14.0",
"react-dom": "16.14.0",
"react-helmet-async": "1.3.0",
"react-helmet-async": "2.0.5",
"react-router": "5.3.4",
"react-router-dom": "5.3.4",
"serverless": "3.39.0",
Expand Down
5 changes: 4 additions & 1 deletion components/page/src/GovUKPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FC, createElement as h } from 'react';
import { Helmet } from 'react-helmet-async';
import reactHelmetDefault, * as reactHelmetNamed from 'react-helmet-async';
import { Page, PageProps } from './Page';

import favicon from 'govuk-frontend/govuk/assets/images/favicon.ico';
Expand All @@ -12,6 +12,9 @@ import ogImage from 'govuk-frontend/govuk/assets/images/govuk-opengraph-image.pn

import '../assets/GovUKPage.scss';

const reactHelmet = reactHelmetDefault || reactHelmetNamed;
const { Helmet } = reactHelmet;

export type GovUKPageProps = Omit<PageProps, 'govUK'>;

export const GovUKPage: FC<GovUKPageProps> = ({ children, classModifiers, ...props }) => (
Expand Down
5 changes: 4 additions & 1 deletion components/page/src/NotGovUKPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FC, createElement as h } from 'react';
import { Helmet } from 'react-helmet-async';
import reactHelmetDefault, * as reactHelmetNamed from 'react-helmet-async';
import { Page, PageProps } from './Page';

import favicon from '../assets/coat-favicon.ico';
Expand All @@ -11,6 +11,9 @@ import ogImage from '../assets/coat-opengraph-image.png';

import '../assets/NotGovUKPage.scss';

const reactHelmet = reactHelmetDefault || reactHelmetNamed;
const { Helmet } = reactHelmet;

export type NotGovUKPageProps = Omit<PageProps, 'govUK'>;

export const NotGovUKPage: FC<NotGovUKPageProps> = ({ children, classModifiers, ...props }) => (
Expand Down
5 changes: 4 additions & 1 deletion components/page/src/Page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FC, Fragment, HTMLProps, ReactNode, createElement as h } from 'react';
import { Helmet } from 'react-helmet-async';
import reactHelmetDefault, * as reactHelmetNamed from 'react-helmet-async';
import { BackLink } from '@not-govuk/back-link';
import { Breadcrumb, Breadcrumbs } from '@not-govuk/breadcrumbs';
import { StandardProps, classBuilder } from '@not-govuk/component-helpers';
Expand All @@ -12,6 +12,9 @@ import { WidthContainer } from '@not-govuk/width-container';

import '../assets/Page.scss';

const reactHelmet = reactHelmetDefault || reactHelmetNamed;
const { Helmet } = reactHelmet;

export type PageProps = (
StandardProps &
HTMLProps<HTMLDivElement> &
Expand Down
10 changes: 7 additions & 3 deletions lib/app-composer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { GraphQLSchema } from 'graphql';
import { ApolloClient, ApolloProvider, InMemoryCache, createHttpLink } from '@apollo/client';
import { SchemaLink } from '@apollo/client/link/schema';
import { ComponentType, Fragment, ReactNode, Suspense, createElement as h, lazy } from 'react';
import { Helmet, HelmetProvider, FilledContext } from 'react-helmet-async';
import { Helmet, HelmetProvider, HelmetServerState } from 'react-helmet-async';
import { StaticRouter, StaticRouterProps, Switch } from 'react-router';
import { BrowserRouter, BrowserRouterProps } from 'react-router-dom';
import { Route, RouteComponentProps, withRouter } from '@not-govuk/route-utils';
Expand Down Expand Up @@ -54,6 +54,10 @@ type ServerError = {
message: string
};

export type HelmetDataContext = {
helmet: HelmetServerState
}

export type ApplicationPropsSSR = ApplicationPropsCommon & {
pages: PageInfoSSR[]
};
Expand All @@ -63,7 +67,7 @@ export type ApplicationProps = ApplicationPropsCSR | ApplicationPropsSSR;
type ApplicationCSR = ComponentType<ApplicationPropsCSR>;
type ApplicationSSR = ComponentType<ApplicationPropsSSR> & {
extractDataCache: () => object
helmetContext: FilledContext
helmetContext: HelmetDataContext
};
export type Application = ComponentType<ApplicationProps>;

Expand Down Expand Up @@ -304,7 +308,7 @@ export const compose: Compose = options => {

return Object.assign(App, {
extractDataCache,
helmetContext: helmetContext as FilledContext
helmetContext: helmetContext as HelmetDataContext
});
};

Expand Down
5 changes: 4 additions & 1 deletion lib/component-test-helpers/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { FC, ReactElement, ReactNode, createElement as h } from 'react';
import { HelmetProvider } from 'react-helmet-async';
import reactHelmetDefault, * as reactHelmetNamed from 'react-helmet-async';
import { MemoryRouter } from 'react-router';
import { render as _render, RenderOptions } from '@testing-library/react';
import userEventDefault from '@testing-library/user-event';

import '@testing-library/jest-dom';

const reactHelmet = reactHelmetDefault || reactHelmetNamed;
const { HelmetProvider } = reactHelmet;

const Providers: FC<{ children?: ReactNode, routerProps?: object }> = ({
children,
routerProps
Expand Down
2 changes: 1 addition & 1 deletion lib/server-renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@types/react": "16.14.60",
"@types/react-dom": "16.9.24",
"graphql": "15.9.0",
"react-helmet-async": "1.3.0",
"react-helmet-async": "2.0.5",
"typescript": "4.9.5"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"process": "^0.11.10",
"react": "16.14.0",
"react-dom": "16.14.0",
"react-helmet-async": "1.3.0",
"react-helmet-async": "2.0.5",
"react-router": "5.3.4",
"react-router-dom": "5.3.4",
"ts-jest": "29.2.3",
Expand Down
70 changes: 31 additions & 39 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading