Skip to content

Commit

Permalink
fix: document no exist in ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Feb 11, 2022
1 parent 5532138 commit 19191fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .umirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export default defineConfig({
logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
outputPath: '.doc',
exportStatic: {},
base: '/',
publicPath: '/',
base: '/cssinjs/',
publicPath: '/cssinjs/',
hash: true,
styles: [
`
Expand Down
10 changes: 6 additions & 4 deletions src/useCacheToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ function recordCleanToken(tokenKey: string) {
}

function removeStyleTags(key: string) {
const styles = document.querySelectorAll(`style[data-token-key="${key}"]`);
if (typeof document !== 'undefined') {
const styles = document.querySelectorAll(`style[data-token-key="${key}"]`);

styles.forEach((style) => {
style.parentNode?.removeChild(style);
});
styles.forEach((style) => {
style.parentNode?.removeChild(style);
});
}
}

// Remove will check current keys first
Expand Down

0 comments on commit 19191fc

Please sign in to comment.