All files / src/motion/utils VisualElementHandler.tsx

100% Statements 17/17
100% Branches 2/2
100% Functions 5/5
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3133x                   33x       33x 355x 355x     33x   33x 355x 355x     33x 1410x   33x  
import React from "react"
import { MotionConfigProps } from "../.."
import { VisualElement } from "../../render/types"
import { MotionProps } from "../types"
 
interface Props {
    visualElement?: VisualElement
    props: MotionProps & MotionConfigProps
}
 
export class VisualElementHandler extends React.Component<Props> {
    /**
     * Update visual element props as soon as we know this update is going to be commited.
     */
    getSnapshotBeforeUpdate() {
        this.updateProps()
        return null
    }
 
    componentDidUpdate() {}
 
    updateProps() {
        const { visualElement, props } = this.props
        if (visualElement) visualElement.setProps(props)
    }
 
    render() {
        return this.props.children
    }
}