Javascript - Animated - 'UseNativeDriver' Was Not Specified Issue of ReactNativeBase Input - Stack Overflow
Javascript - Animated - 'UseNativeDriver' Was Not Specified Issue of ReactNativeBase Input - Stack Overflow
ReactNativeBase Input
Asked 3 years, 10 months ago Modified 11 months ago Viewed 121k times
I created a new react-native project today (April 3rd, 2020) and added a native-base. Then
I tried to add input with the floating label. It gives a warning message:
Animated:
76 useNativeDriver was not specified. This is a required option and must be explicitly
set to true or false . If I removed the floating label attribute or changed it to
stackedLabel the warning disappeared. While this warning is appearing, onChangeText is
not being called.
Component File
import React from 'react';
import {
SafeAreaView,
ScrollView,
StatusBar,
StyleSheet,
View,
} from 'react-native';
package.json
{
"name": "formtest",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"dependencies": {
"native-base": "^2.13.12",
"react": "16.11.0",
"react-native": "0.62.0"
},
"devDependencies": {
"@babel/core": "^7.6.2",
"@babel/runtime": "^7.6.2",
"@react-native-community/eslint-config": "^1.0.0",
"@types/jest": "^24.0.24",
"@types/react-native": "^0.62.0",
"@types/react-test-renderer": "16.9.2",
"@typescript-eslint/eslint-plugin": "^2.25.0",
"@typescript-eslint/parser": "^2.25.0",
"babel-jest": "^24.9.0",
"eslint": "^6.5.1",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.58.0",
"react-test-renderer": "16.11.0",
"prettier": "^2.0.2",
"typescript": "^3.8.3"
},
"jest": {
"preset": "react-native",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
]
}
}
Share Improve this question edited Mar 2, 2023 at 14:50 asked Apr 3, 2020 at 14:57
Follow meaning-matters Supun Induwara
22.3k 10 84 145 1,632 3 15 23
UPDATED
Solution:
As the warning says, we need to specify the option explicitly and set it to
useNativeDriver
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
Share Improve this answer edited Aug 25, 2021 at 22:22 answered Apr 9, 2020 at 9:23
Follow Javascript Addicted
13.5k 7 70 79
Hi, may i know where to find and edit the Animated.timing? – kaizen Jul 3, 2020 at 9:37
you can not simply add another answer in your answer without specifying his/her name
– Nisharg Shah Nov 2, 2020 at 13:47
@Nisharg Shah - That's your right, but I read that in github.com :
github.com/GeekyAnts/NativeBase/issues/… I removed it from my answer, as I told I read that in
Github – Javascript Addicted Nov 2, 2020 at 15:23
No issues but you must specify the name if you update your answer after some person add the
same answer in your post, that's why I told you and these the regular behavior of SO
– Nisharg Shah Nov 2, 2020 at 16:46
github.com/GeekyAnts/NativeBase/issues/… – Javascript Addicted Nov 2, 2020 at 22:15
Facing the same issue for a long time and still no update from native-base developers yet
in 2021.
32 Meanwhile use a workaround to avoid irritating yellow warnings of .
useNativeDriver
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`']);
}
useEffect(() => {
YellowBox.ignoreWarnings(['Animated: `useNativeDriver`']);
}, [])
CLASS BASED
import React from 'react';
import { YellowBox } from 'react-native';
componentDidMount() {
YellowBox.ignoreWarnings(['Animated: `useNativeDriver`']);
}
Share Improve this answer edited Jun 27, 2021 at 17:06 answered Aug 21, 2020 at 9:09
Follow Nisharg Shah
17.9k 11 63 74
1 That helped me out – Zeeshan Ahmad Khalil Oct 22, 2020 at 7:03
1 what does functional mean? where should I add this? would that work for all the apperances of
the message? – Diego Rivera Nov 3, 2020 at 2:28
React is written in two styles, Functional based and class based, you must to add that code in
those, where you want to ignore those warning – Nisharg Shah Nov 3, 2020 at 2:44
5 Idk I'm just saying it's a warning and hiding the warning is not the same as fixing the warning
yeah? But I am also going to hide the warning for now since it's not fixed yet.
– Charitha Goonewardena Jan 25, 2021 at 17:58
Didn't work! Tried adding it to the UI file as well as test file. – cmcodes Mar 9, 2022 at 12:35
Share Improve this answer Follow answered Sep 27, 2020 at 11:33
Karthikeyan Ganesan
1,919 20 24
Share Improve this answer Follow answered Sep 24, 2020 at 22:36
ziishaned
5,174 3 27 32
Using class Component just add the Animated.timing inside componentDidMount() and
define useNativeDriveras true or false
0 class App extends Component {
componentDidMount() {
Animated.timing(this.animatedValue,
{
toValue: 1,
duration: 1000,
useNativeDriver: true
}).start();
}
render() {
return (
<View style={styles.container}>
<View style={styles.squareBG}/>
<Animated.View style={[styles.square, {opacity:
this.animatedValue}]}/>
</View>
);
}
}
Share Improve this answer Follow answered Jul 25, 2020 at 10:04
anehme
536 1 6 18
I just added this in my App.js and worked for me :)
0 import { YellowBox } from 'react-native';
YellowBox.ignoreWarnings([
'Animated: `useNativeDriver` was not specified.',
]);
Share Improve this answer Follow answered Jul 29, 2020 at 22:55
Erick
27 2
So this is the solution if you are getting this type of warning in your terminal. Warning:
dynamic: useNativeDriver was not defined. This is a required option and must be explicitly
0 set to 'true' or 'false'.
I tried to remove this warning with YellowBox.ignoreWarnings(['Animated:
useNativeDriver ']) and then got this warning.
Warn:YellowBox has been replaced by LogBox. Please call LogBox.ignoreLogs() instead.
So I found this and it is working fine in my project. LogBox.ignoreLogs(['Driver:
`useNativeDriver'']) add this line in index.js folder.
Share Improve this answer Follow answered Feb 6, 2023 at 8:33
zikran shakeel
1 1
Share Improve this answer Follow answered Sep 12, 2022 at 7:14
ND verma
201 3 10
This is not a solution to the issue flagged but instead a way to hide the warning and pretend it
doesn't exist. – Patrick Lafferty May 22, 2023 at 13:36
7 If you make changes like this you will most likely want to use the 'patch-package' module in order
to generate a patch of the changes you made and automatically apply them if/when
node_modules is reinstalled – Mike Hardy Apr 18, 2020 at 23:18