New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move conditional useInsertionEffect
declarations into separate package
#2867
Changes from 3 commits
8dc0645
c2f0ce5
dfbe3af
398c1fb
226604c
5be51df
19e8bed
ea5a2ea
273192d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) Emotion team and other contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# @emotion/use-insertion-effect-with-fallbacks |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,38 @@ | ||||||
{ | ||||||
"name": "@emotion/use-insertion-effect-with-fallbacks", | ||||||
"version": "1.0.0", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
+a changeset |
||||||
"description": "", | ||||||
"main": "dist/emotion-use-insertion-effect-with-fallbacks.cjs.js", | ||||||
"module": "dist/emotion-use-insertion-effect-with-fallbacks.esm.js", | ||||||
"browser": { | ||||||
"./dist/emotion-use-insertion-effect-with-fallbacks.esm.js": "./dist/emotion-use-insertion-effect-with-fallbacks.browser.esm.js" | ||||||
}, | ||||||
"license": "MIT", | ||||||
"repository": "https://github.com/emotion-js/emotion/tree/main/packages/use-insertion-effect-with-fallbacks", | ||||||
"publishConfig": { | ||||||
"access": "public" | ||||||
}, | ||||||
"files": [ | ||||||
"src", | ||||||
"dist" | ||||||
], | ||||||
"exports": { | ||||||
".": { | ||||||
"module": { | ||||||
"worker": "./dist/emotion-use-insertion-effect-with-fallbacks.worker.esm.js", | ||||||
"browser": "./dist/emotion-use-insertion-effect-with-fallbacks.browser.esm.js", | ||||||
"default": "./dist/emotion-use-insertion-effect-with-fallbacks.esm.js" | ||||||
}, | ||||||
"default": "./dist/emotion-use-insertion-effect-with-fallbacks.cjs.js" | ||||||
}, | ||||||
"./package.json": "./package.json" | ||||||
}, | ||||||
"preconstruct": { | ||||||
"exports": { | ||||||
"envConditions": [ | ||||||
"browser", | ||||||
"worker" | ||||||
] | ||||||
} | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as React from 'react' | ||
|
||
const isBrowser = typeof document !== 'undefined' | ||
|
||
const syncFallback = create => create() | ||
|
||
const useInsertionEffect = React['useInsertion' + 'Effect'] | ||
? React['useInsertion' + 'Effect'] | ||
: false | ||
|
||
export const useInsertionEffectAlwaysWithSyncFallback = !isBrowser | ||
? syncFallback | ||
: useInsertionEffect || syncFallback | ||
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please be extra careful when reviewing this as the shape of this has slightly changed when I moved this. I think that the current code is functionally equivalent to the old version though. |
||
|
||
export const useInsertionEffectWithLayoutFallback = | ||
useInsertionEffect || React.useLayoutEffect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
*-with-fallback
or*-with-fallbacks
? 😅 #realproblems