Skip to content

Commit

Permalink
fix(react): force interop check to fix @emotion/is-prop-valid esm imp…
Browse files Browse the repository at this point in the history
…ort (#1097)

* fix(react): force interop check to fix @emotion/is-prop-valid esm import

* fix(react): force interop - .changeset
  • Loading branch information
andparsons committed Oct 25, 2022
1 parent 5b0990f commit c26d466
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/wild-hairs-grin.md
@@ -0,0 +1,5 @@
---
'@linaria/react': patch
---

force interop check to fix @emotion/is-prop-valid esm import
9 changes: 8 additions & 1 deletion packages/react/src/styled.ts
Expand Up @@ -65,8 +65,15 @@ function filterProps<T extends Record<string, unknown>, TKeys extends keyof T>(
component.indexOf('-') === -1 &&
!isCapital(component[0])
) {
/**
* A failsafe check for esModule import issues
* if validAttr !== 'function' then it is an object of { default: Fn }
*/
const interopValidAttr =
typeof validAttr === 'function' ? { default: validAttr } : validAttr;

Object.keys(filteredProps).forEach((key) => {
if (!validAttr(key)) {
if (!interopValidAttr.default(key)) {
// Don't pass through invalid attributes to HTML elements
delete filteredProps[key];
}
Expand Down

0 comments on commit c26d466

Please sign in to comment.