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

jasan-s picture jasan-s  路  23Comments

amang8662 picture amang8662  路  92Comments

nelsonprsousa picture nelsonprsousa  路  38Comments

arelstone picture arelstone  路  36Comments

mrousavy picture mrousavy  路  29Comments