oblador / react-native-animatable

Standard set of easy to use animations and declarative transitions for React Native
MIT License
9.84k stars 702 forks source link

Issue with slideOutUp when using with typescript #237

Closed NotTooReact89 closed 4 years ago

NotTooReact89 commented 5 years ago

Hi there,

I am using react-native-animatable with typescript but I get an error. Please find the attached image.

screen shot 2018-12-20 at 2 42 47 pm

aaronfg commented 4 years ago

I've gotten this too but in my functional components using the useRef hook.

My workaround was adding the animation to the conditional before I call it:

if (myRef && myRef.current && myRef.current.slideOutUp) {
    myRef.current?.slideOutUp();
}

Which removes my linter complaining. My guess is you could add the same check to your class component, ie:

if (this.banner.slideOutUp){
    this.banner.slideOutUp(animationDuration).then(this.props.onPress;
}