Skip to content

Commit

Permalink
FIX Reuse emotion cache to avoid conflicts
Browse files Browse the repository at this point in the history
Creating a new emotion cache for each provider can result in clashes
  • Loading branch information
GuySartorelli committed Jan 19, 2023
1 parent 9e30f7d commit 6b803eb
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ import { CacheProvider } from '@emotion/react';
* the default react-select styling
*/
function EmotionCssCacheProvider({ children }) {
const cache = React.useMemo(
() => createCache({
key: 'react-select',
insertionPoint: document.querySelector('title'),
}),
[]
);
if (!window.ssReactSelectCache) {
window.ssReactSelectCache = React.useMemo(
() => createCache({
key: 'react-select',
insertionPoint: document.querySelector('title'),
}),
[]
);
}

return <CacheProvider value={cache}>{children}</CacheProvider>;
return <CacheProvider value={window.ssReactSelectCache}>{children}</CacheProvider>;
}

export default EmotionCssCacheProvider;

0 comments on commit 6b803eb

Please # to comment.