import {Component} from 'react'; import {motion} from 'framer-motion'; import testableTransition from 'sentry/utils/testableTransition'; type RenderProps = { fallCount: number; fallingError: React.ReactNode; isFalling: boolean; triggerFall: (countIt?: boolean) => void; }; type Props = { children: (renderProps: RenderProps) => React.ReactNode; onFall?: (fallCount: number) => void; }; type State = { fallCount: number; isFalling: boolean; }; class FallingError extends Component { state: State = { isFalling: false, fallCount: 0, }; triggerFall = (countIt?: boolean) => this.setState(s => { const fallCount = s.fallCount + (countIt ? 1 : 0); this.props.onFall?.(fallCount); return {...s, isFalling: true, fallCount}; }); render() { const {isFalling, fallCount} = this.state; const fallingError = ( variant === 'falling' && this.setState({isFalling: false}) } > {!isFalling ? ( this.triggerFall(true)} > ) : ( )} ); return this.props.children({ fallCount, fallingError, triggerFall: this.triggerFall, isFalling, }); } } export default FallingError;