File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -88,3 +88,11 @@ export const flushCalls = <T extends AnyFn>(
88
88
queue : Set < T > ,
89
89
...args : Parameters < T >
90
90
) => flush ( queue , fn => fn ( ...args ) )
91
+
92
+ // For server-side rendering: https://github.com/react-spring/zustand/pull/34
93
+ // Deno support: https://github.com/pmndrs/zustand/issues/347
94
+
95
+ export const isSSR = ( ) =>
96
+ typeof window === 'undefined' ||
97
+ ! window . navigator ||
98
+ / S e r v e r S i d e R e n d e r i n g | ^ D e n o \/ / . test ( window . navigator . userAgent )
Original file line number Diff line number Diff line change 1
1
import * as G from './globals'
2
- import { is } from './helpers'
2
+ import { is , isSSR } from './helpers'
3
3
import { cssVariableRegex } from './regexs'
4
4
5
5
// Not all strings can be animated (eg: {display: "none"})
@@ -8,7 +8,8 @@ export function isAnimatedString(value: unknown): value is string {
8
8
is . str ( value ) &&
9
9
( value [ 0 ] == '#' ||
10
10
/ \d / . test ( value ) ||
11
- cssVariableRegex . test ( value ) ||
11
+ // Do not identify a CSS variable as an AnimatedString if its SSR
12
+ ( ! isSSR ( ) && cssVariableRegex . test ( value ) ) ||
12
13
value in ( G . colors || { } ) )
13
14
)
14
15
}
Original file line number Diff line number Diff line change
1
+ import { isSSR } from './helpers'
1
2
import { cssVariableRegex } from './regexs'
2
3
3
4
/**
@@ -14,7 +15,7 @@ import { cssVariableRegex } from './regexs'
14
15
export const variableToRgba = ( input : string ) : string => {
15
16
const [ token , fallback ] = parseCSSVariable ( input )
16
17
17
- if ( ! token ) {
18
+ if ( ! token || isSSR ( ) ) {
18
19
return input
19
20
}
20
21
You can’t perform that action at this time.
0 commit comments