Animated: `useNativeDriver` was not specified issue of ReactNativeBase Input
Just add useNativeDriver: true
to the animation config.
const [animatePress, setAnimatePress] = useState(new Animated.Value(1))
const animateIn = () => {
Animated.timing(animatePress, {
toValue: 0.5,
duration: 500,
useNativeDriver: true // Add This line
}).start();
}
UPDATED
Solution:
As the warning says, we need to specify the useNativeDriver
option explicitly and set it to true
or false
.
1- Animation methods
Refer to Animated doc , with animation types or composition functions, for example, Animated.decay()
, Animated.timing()
,
Animated.spring()
, Animated.parallel()
, Animated.sequence()
, specify useNativeDriver
.
Animated.timing(this.state.animatedValue, {
toValue: 1,
duration: 500,
useNativeDriver: true, // Add this line
}).start();
2- Animatable components
Animated
exports the following animatable components using the above wrapper:
Animated.Image
Animated.ScrollView
Animated.Text
Animated.View
Animated.FlatList
Animated.SectionList
When working with Animated.event()
, add useNativeDriver: false/true
to the animation config.
<Animated.ScrollView
scrollEventThrottle={1}
onScroll={Animated.event(
[{ nativeEvent: { contentOffset: { y: this.state.animatedValue } } }],
{ useNativeDriver: true } // Add this line
)}
>
{content}
</Animated.ScrollView>
Facing the same issue for a long time and still no update from native-base developers yet in 2021.
Meanwhile use a workaround to avoid irritating yellow warnings of useNativeDriver
.
UPDATE RN V0.63 ABOVE
YellowBox
is now changed and replace with LogBox
FUNCTIONAL
import React, { useEffect } from 'react';
import { LogBox } from 'react-native';
useEffect(() => {
LogBox.ignoreLogs(['Animated: `useNativeDriver`']);
}, [])
CLASS BASED
import React from 'react';
import { LogBox } from 'react-native';
componentDidMount() {
LogBox.ignoreLogs(['Animated: `useNativeDriver`']);
}
UPDATE RN V0.63 BELOW
FUNCTIONAL
import React, { useEffect } from 'react';
import { YellowBox } from 'react-native';
useEffect(() => {
YellowBox.ignoreWarnings(['Animated: `useNativeDriver`']);
}, [])
CLASS BASED
import React from 'react';
import { YellowBox } from 'react-native';
componentDidMount() {
YellowBox.ignoreWarnings(['Animated: `useNativeDriver`']);
}