React-native-vector-icons: Please provide better example for Animated icon!

Created on 13 Mar 2020  路  2Comments  路  Source: oblador/react-native-vector-icons

import Icon from 'react-native-vector-icons/EvilIcons';

const AnimatedIcon = Animated.createAnimatedComponent(Icon);

const App: () => React$Node = () => {
  return (
     <AnimatedIcon name="spinner-3" size={ 64 } />
  );
};

Nothing happens. No idea why. React-Native documentation does not really help.

Most helpful comment

Thank you @KaoPengHsiang !

All 2 comments

@yanickrochon
I try to change a simple example from website like this below. And it works!
Maybe this could help you a little :D ?

import Icon from 'react-native-vector-icons/EvilIcons';
const AnimatedIcon = Animated.createAnimatedComponent(Icon);
class abc extends Component {
...
  animVal = new Animated.Value(0);
  animatedTransition = Animated.spring(this.animVal, { toValue: 1 })
  interpolateIcon = this.animVal.interpolate({ inputRange: [0, 1], outputRange: [0, 1] })

  componentDidMount() {
    this.animatedTransition.start()
  }
  render(){ 
     return( 
    <AnimatedIcon name="like" size={64} style={{ paddingLeft: 10, paddingRight: 10, transform: [{ 
    scale: this.interpolateIcon }] }} />  );
  }
}

Thank you @KaoPengHsiang !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

peacechen picture peacechen  路  3Comments

fevzican picture fevzican  路  3Comments

arjs1000 picture arjs1000  路  3Comments

emretekince picture emretekince  路  4Comments

rmilejcz picture rmilejcz  路  3Comments