Skip to content

Conversation

@mattgperry
Copy link
Collaborator

@mattgperry mattgperry commented Nov 26, 2018

Changing this pattern:

const x = useMotionValue(0)

return <Component x={x} />

To:

const x = useMotionValue(0)

return <Component motionValues={{ x }} />

This will allow us to more strongly type this kind of attribute without whitelisting, and also remove the presumption that this kind of thing is possible:

<Component x={20} />

{ onPoseComplete, pose = "default", motionValues, ...props }: MotionProps,
ref: RefObject<Element>
): [MotionValueMap, Partial<MotionProps>] => {
const values: MotionValueMap = useRef(new Map()).current
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This map could be typed

Object.keys(motionValues).forEach(key => {
const motionValue = motionValues[key]

if (motionValue instanceof MotionValue) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make a habit out of using isMotionValue For this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants