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
Adding isValidProp to MotionConfig #1410
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 8e7667a:
|
1ea3c2b
to
bc17fa7
Compare
|
||
const { container } = render(<Component />) | ||
|
||
expect(container.firstChild).not.toHaveAttribute("data-foo") |
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 we also test that a valid attribute is forwarded to the DOM?
src/render/dom/utils/filter-props.ts
Outdated
@@ -3,6 +3,16 @@ import { isValidMotionProp } from "../../../motion/utils/valid-prop" | |||
|
|||
let shouldForward = (key: string) => !isValidMotionProp(key) | |||
|
|||
export type IsValidProp = (key: string) => boolean | |||
|
|||
export function loadExternalIsValidProp(emotionIsPropValid?: IsValidProp) { |
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.
Why do we still call it emotionIsPropValid
if it could be a user-provided function?
src/render/dom/utils/filter-props.ts
Outdated
|
||
// Handle events explicitly as Emotion validates them all as true | ||
shouldForward = (key: string) => | ||
key.startsWith("on") ? !isValidMotionProp(key) : emotionIsPropValid(key) |
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.
If there's an injected isValidProp
provided by MotionConfig
, wouldn't it be hijacked by isValidMotionProp
? For example, isValidProp={key => key !== "onStart"}
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.
I think that might have to be a limitation of the API that our events are always consumed
bc17fa7
to
2f7ba17
Compare
@shuangq Great comments, I've just pushed some changes |
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.
LGTM 👏
This PR adds an
isValidProp
prop toMotionConfig
that allows the external injection of anisValidProp
function.Fixes #1406