react-native-progress-bar-animated icon indicating copy to clipboard operation
react-native-progress-bar-animated copied to clipboard

Native Driver warning leads to force close and apps reload.

Open johfarrell opened this issue 4 years ago • 12 comments

WARN useNativeDriver was not specified. This is a required option and must be explicitly set to true or false. In my case, after getting this warn, the view reload itself.

johfarrell avatar Sep 02 '20 02:09 johfarrell

me too

t880216t avatar Oct 14 '20 14:10 t880216t

I fixed this by adding: userNativeDriver: true,

To AnimatedProgressBar.js

animateWidth() {
    const toValue = ((this.props.width * this.state.progress) / 100) - this.props.borderWidth * 2;

    Animated.timing(this.widthAnimation, {
      easing: Easing[this.props.barEasing],
      toValue: toValue > 0 ? toValue : 0,
      duration: this.props.barAnimationDuration,
      userNativeDriver: true,
    }).start();
  }

  animateBackground() {
    Animated.timing(this.backgroundAnimation, {
      toValue: 1,
      duration: this.props.backgroundAnimationDuration,
      userNativeDriver: true,
    }).start();
  }

bfarrgaynor avatar Jan 21 '21 13:01 bfarrgaynor

I fixed this by adding: userNativeDriver: true,

To AnimatedProgressBar.js

animateWidth() {
    const toValue = ((this.props.width * this.state.progress) / 100) - this.props.borderWidth * 2;

    Animated.timing(this.widthAnimation, {
      easing: Easing[this.props.barEasing],
      toValue: toValue > 0 ? toValue : 0,
      duration: this.props.barAnimationDuration,
      userNativeDriver: true,
    }).start();
  }

  animateBackground() {
    Animated.timing(this.backgroundAnimation, {
      toValue: 1,
      duration: this.props.backgroundAnimationDuration,
      userNativeDriver: true,
    }).start();
  }

I already made a pull request on that the day I reported the issue. Still no response from the owner.

johfarrell avatar Jan 21 '21 14:01 johfarrell

Any update?

denisvely avatar May 20 '21 07:05 denisvely

I resolved. You should add library code useNativeDriver: true (or false)!

jejecrunch avatar Jul 26 '21 05:07 jejecrunch

I resolved. You should add library code useNativeDriver: true (or false)!

Not Working

denisvely avatar Aug 10 '21 12:08 denisvely

Any updates? it's just one row please update it that warn drives me mad.

denisvely avatar Aug 20 '21 12:08 denisvely

Any updates? it's just one row please update it that warn drives me mad.

Still waiting for the merge mate.😅

johfarrell avatar Aug 20 '21 12:08 johfarrell

Any updates?? I am also getting this useNativeDriver warning.

MuflahNasir avatar Sep 15 '21 13:09 MuflahNasir

Hi just as a quick fix you can create this file as patches/react-native-progress-bar-animated+1.0.6.patch in your root repo dir and set it's value to

diff --git a/node_modules/react-native-progress-bar-animated/src/AnimatedProgressBar.js b/node_modules/react-native-progress-bar-animated/src/AnimatedProgressBar.js
index 8ba19be..4963b58 100644
--- a/node_modules/react-native-progress-bar-animated/src/AnimatedProgressBar.js
+++ b/node_modules/react-native-progress-bar-animated/src/AnimatedProgressBar.js
@@ -61,6 +61,7 @@ class ProgressBar extends React.Component {
       easing: Easing[this.props.barEasing],
       toValue: toValue > 0 ? toValue : 0,
       duration: this.props.barAnimationDuration,
+      useNativeDriver: false
     }).start();
   }

then run yarn patch-package to fix that.

You can also add it to your package.json file for a more automated workflow:

 "scripts": {
+  "postinstall": "patch-package"
 }

itamarbareket avatar Nov 05 '21 21:11 itamarbareket

Any updates??

toniellenk avatar Jul 16 '22 16:07 toniellenk

Any updates??

Hey man, i dont think this will ever be merged but its easy to apply yourself. Since he probably isn't ever going to be updated again i've made my own patch using https://www.npmjs.com/package/patch-package including Lineargradient from expo-linear-gradient https://docs.expo.dev/versions/latest/sdk/linear-gradient/. I also did as some here have done and added useNativeDriver: false on 3 lines in the AnimatedProgressBar.js file. My full patch is on the LinearGradient issue: #22 Hope this helps !

Jip-bot avatar Jul 20 '22 10:07 Jip-bot