Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
values: MotionValuesMap,
styleProp: MotionStyle = {},
transformValues?: (values: V) => V
): CSSProperties => {
const style = useRef({}).current
const prevMotionStyles = useRef({}).current
const currentStyleKeys = new Set(Object.keys(style))
for (const key in styleProp) {
currentStyleKeys.delete(key)
const thisStyle = styleProp[key]
if (isMotionValue(thisStyle)) {
// If this is a motion value, add it to our MotionValuesMap
values.set(key, thisStyle)
} else if (isTransformProp(key) || isTransformOriginProp(key)) {
// Or if it's a transform prop, create a motion value (or update an existing one)
// to ensure Stylefire can reconcile all the transform values together.
if (!values.has(key)) {
// If it doesn't exist as a motion value, create it
values.set(key, motionValue(thisStyle))
} else {
// Otherwise only update it if it's changed from a previous render
if (thisStyle !== prevMotionStyles[key]) {
const value = values.get(key) as MotionValue
value.set(thisStyle)
}
}
prevMotionStyles[key] = thisStyle
} else {
style[key] = thisStyle