Skip to content

Commit

Permalink
🐛 fix: fix global undefined when using vite (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Nov 1, 2023
1 parent c2c073d commit 1cc076d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/factories/createStyleProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ export const createStyleProvider = (EmotionContext: Context<Emotion>): FC<StyleP
stylisPlugins,
});

const cacheManager = global?.__ANTD_STYLE_CACHE_MANAGER_FOR_SSR__;
if (typeof global !== 'undefined') {
const cacheManager = global.__ANTD_STYLE_CACHE_MANAGER_FOR_SSR__;

if (cacheManager) {
// add 方法有幂等
instance.cache = cacheManager.add(instance.cache);
if (cacheManager) {
// add 方法有幂等
instance.cache = cacheManager.add(instance.cache);
}
}

return instance;
Expand Down

0 comments on commit 1cc076d

Please sign in to comment.