Skip to content

Commit

Permalink
use separate emotion 'cache' for pinboard (to avoid it fighting/racin…
Browse files Browse the repository at this point in the history
…g the host application if it uses emotion, e.g. prosemirror in Composer)

Co-authored-by: Rebecca Thompson <[email protected]>
  • Loading branch information
twrichards and rebecca-thompson committed Aug 8, 2023
1 parent f7e01b4 commit c80a621
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions client/src/entry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {
} from "@guardian/user-telemetry-client";
import { IPinboardEventTags, TelemetryContext } from "./types/Telemetry";
import { APP } from "../../shared/constants";
import { CacheProvider } from "@emotion/react";
import createCache from "@emotion/cache";

const SENTRY_REROUTED_FLAG = "rerouted";

Expand Down Expand Up @@ -220,13 +222,18 @@ export function mount({

document.body.appendChild(element);

// to ensure no conflict with host application's emotion cache
const emotionCache = createCache({ key: "pinboard-emotion-cache" });

render(
<TelemetryContext.Provider value={sendTelemetryEvent}>
<PinBoardApp
apolloClient={apolloClient}
userEmail={userEmail}
hasApolloAuthErrorVar={hasApolloAuthErrorVar}
/>
<CacheProvider value={emotionCache}>
<PinBoardApp
apolloClient={apolloClient}
userEmail={userEmail}
hasApolloAuthErrorVar={hasApolloAuthErrorVar}
/>
</CacheProvider>
</TelemetryContext.Provider>,
element
);
Expand Down

0 comments on commit c80a621

Please sign in to comment.