joeyschroeder / react-native-simple-animations

🌈 A React Native component that adds simple entrance, exit, and attention-seeking animations to a child component.
https://www.npmjs.com/package/react-native-simple-animations
Other
27 stars 4 forks source link

issue with aim property #1

Closed cellezam closed 5 years ago

cellezam commented 5 years ago

Hi,

Great Dependencies and weight. I love it. I have an issue with the aim property. The component does not update his state when trying to change in and out onPress on a button. Here is an "example" of my code :

class extend .......
constructor(props) {
        super(props);
        this.state = {
            InOrOut: "in"
        }
    }

<SimpleAnimation
                delay={1000}
                duration={1000}
                fade
                staticType='zoom'
                aim={this.state.InOrOut}
            >
<Button onPress={this.updateCategorie}>blabla</Button>
</SimpleAnimation>

updateCategorie(cat){
        console.log(cat);
        this.setState({
            InOrOut: "out"
        })
    }
joeyschroeder commented 5 years ago

Hey there @ChalomEllezam,

I'm taking a look at this now.

joeyschroeder commented 5 years ago

@ChalomEllezam It appears in your code sample the prop animateOnUpdate is not set. By default this prop is set to false. When animateOnUpdate is true the animation will fire every time one of it's props updates.

There is an example of this working in the example app included in this project.

In short, please add the animateOnUpdate prop to <SimpleAnimation />:

...
render() {
  return (
    <SimpleAnimation
      delay={1000}
      duration={1000}
      fade
      staticType='zoom'
      aim={this.state.InOrOut}
      animateOnUpdate
    >
      <Button onPress={this.updateCategorie}>blabla</Button>
    </SimpleAnimation>
  )
}
...

Let me know if the component animation still isn't triggering when this prop changes.

joeyschroeder commented 5 years ago

@ChalomEllezam I'm closing this issue due to inactivity. Feel free to open another if animateOnUpdate doesn't solve your issue. Thanks!