File tree Expand file tree Collapse file tree 7 files changed +32
-20
lines changed
packages/use-insertion-effect-with-fallbacks Expand file tree Collapse file tree 7 files changed +32
-20
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @emotion/use-insertion-effect-with-fallbacks ' : minor
3
+ ---
4
+
5
+ Source code has been migrated to TypeScript. From now on type declarations will be emitted based on that, instead of being hand-written.
Original file line number Diff line number Diff line change 4
4
"description" : " A wrapper package that uses `useInsertionEffect` or a fallback for it" ,
5
5
"main" : " dist/emotion-use-insertion-effect-with-fallbacks.cjs.js" ,
6
6
"module" : " dist/emotion-use-insertion-effect-with-fallbacks.esm.js" ,
7
+ "types" : " dist/emotion-use-insertion-effect-with-fallbacks.cjs.d.ts" ,
7
8
"license" : " MIT" ,
8
9
"repository" : " https://github.com/emotion-js/emotion/tree/main/packages/use-insertion-effect-with-fallbacks" ,
9
10
"publishConfig" : {
53
54
},
54
55
"imports" : {
55
56
"#is-browser" : {
56
- "edge-light" : " ./src/conditions/false.js " ,
57
- "workerd" : " ./src/conditions/false.js " ,
58
- "worker" : " ./src/conditions/false.js " ,
59
- "browser" : " ./src/conditions/true.js " ,
60
- "default" : " ./src/conditions/is-browser.js "
57
+ "edge-light" : " ./src/conditions/false.ts " ,
58
+ "workerd" : " ./src/conditions/false.ts " ,
59
+ "worker" : " ./src/conditions/false.ts " ,
60
+ "browser" : " ./src/conditions/true.ts " ,
61
+ "default" : " ./src/conditions/is-browser.ts "
61
62
}
62
63
}
63
64
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import * as React from 'react'
2
+ import isBrowser from '#is-browser'
3
+
4
+ const syncFallback = < T > ( create : ( ) => T ) => create ( )
5
+
6
+ const useInsertionEffect = React [
7
+ ( 'useInsertion' + 'Effect' ) as 'useInsertionEffect'
8
+ ]
9
+ ? ( React [ ( 'useInsertion' + 'Effect' ) as 'useInsertionEffect' ] as < T > (
10
+ create : ( ) => T
11
+ ) => T | undefined )
12
+ : false
13
+
14
+ export const useInsertionEffectAlwaysWithSyncFallback : < T > (
15
+ create : ( ) => T
16
+ ) => T | undefined = ! isBrowser
17
+ ? syncFallback
18
+ : useInsertionEffect || syncFallback
19
+
20
+ export const useInsertionEffectWithLayoutFallback : typeof React . useLayoutEffect =
21
+ useInsertionEffect || React . useLayoutEffect
You can’t perform that action at this time.
0 commit comments