Skip to content

"Animated: useNativeDriver was not specified" warning since React Native 0.62 #339

Open

Description

@RadomirKus

Following warning keeps appearing whenever I click on any button or item:

Animated: useNativeDriver was not specified. This is a required option and must be explicitly set to true or false

react-native: 0.62

Activity

  1. blindibrasil commented on Apr 20, 2020

    @blindibrasil

    I think the solution to the problem will be to implement the following change to the ActionButton.js file;

     //////////////////////
      // Animation Methods
      //////////////////////
    
      animateButton(animate = true) {
        if (this.state.active) return this.reset();
    
        if (animate) {
          Animated.spring(this.anim, { toValue: 1, useNativeDriver: false }).start();
        } else {
          this.anim.setValue(1);
        }
    
        this.setState({ active: true, resetToken: this.state.resetToken });
      }
    
      reset(animate = true) {
        if (this.props.onReset) this.props.onReset();
    
        if (animate) {
          Animated.spring(this.anim, { toValue: 0, useNativeDriver: false }).start();
        } else {
          this.anim.setValue(0);
        }
    
        setTimeout(() => {
          if (this.mounted) {
            this.setState({ active: false, resetToken: this.state.resetToken });
          }
        }, 250);
      }
    
  2. sunkakar commented on Jun 16, 2020

    @sunkakar

    I have the same issue!

  3. IgorThierry commented on Jun 25, 2020

    @IgorThierry

    I have the same issue!

  4. ytr0 commented on Jun 29, 2020

    @ytr0

    I think the solution to the problem will be to implement the following change to the ActionButton.js file;

     //////////////////////
      // Animation Methods
      //////////////////////
    
      animateButton(animate = true) {
        if (this.state.active) return this.reset();
    
        if (animate) {
          Animated.spring(this.anim, { toValue: 1, useNativeDriver: false }).start();
        } else {
          this.anim.setValue(1);
        }
    
        this.setState({ active: true, resetToken: this.state.resetToken });
      }
    
      reset(animate = true) {
        if (this.props.onReset) this.props.onReset();
    
        if (animate) {
          Animated.spring(this.anim, { toValue: 0, useNativeDriver: false }).start();
        } else {
          this.anim.setValue(0);
        }
    
        setTimeout(() => {
          if (this.mounted) {
            this.setState({ active: false, resetToken: this.state.resetToken });
          }
        }, 250);
      }
    

    This works.

  5. Sharvin26 commented on Jul 8, 2020

    @Sharvin26

    I think the solution to the problem will be to implement the following change to the ActionButton.js file;

     //////////////////////
      // Animation Methods
      //////////////////////
    
      animateButton(animate = true) {
        if (this.state.active) return this.reset();
    
        if (animate) {
          Animated.spring(this.anim, { toValue: 1, useNativeDriver: false }).start();
        } else {
          this.anim.setValue(1);
        }
    
        this.setState({ active: true, resetToken: this.state.resetToken });
      }
    
      reset(animate = true) {
        if (this.props.onReset) this.props.onReset();
    
        if (animate) {
          Animated.spring(this.anim, { toValue: 0, useNativeDriver: false }).start();
        } else {
          this.anim.setValue(0);
        }
    
        setTimeout(() => {
          if (this.mounted) {
            this.setState({ active: false, resetToken: this.state.resetToken });
          }
        }, 250);
      }
    

    I am also facing the same issue. Manual change works but this warning will always occur every time when the application is rebuilt ( i.e. node_modules are installed again ). Same issue will occur when publishing the app.

    Is there any way we can suppress the warning till the author fixes this issue?

  6. blindibrasil commented on Jul 8, 2020

    @blindibrasil

    I forwarded a message to the author requesting the error correction merge so that this error no longer appears. Now it's time to wait, as they take too long to make changes.
    I believe that you could fork and send your correction to your app because it would be easier and faster, then when you launch the official correction you change.

  7. W8jonas commented on Jul 22, 2020

    @W8jonas

    I think the solution to the problem will be to implement the following change to the ActionButton.js file;

     //////////////////////
      // Animation Methods
      //////////////////////
    
      animateButton(animate = true) {
        if (this.state.active) return this.reset();
    
        if (animate) {
          Animated.spring(this.anim, { toValue: 1, useNativeDriver: false }).start();
        } else {
          this.anim.setValue(1);
        }
    
        this.setState({ active: true, resetToken: this.state.resetToken });
      }
    
      reset(animate = true) {
        if (this.props.onReset) this.props.onReset();
    
        if (animate) {
          Animated.spring(this.anim, { toValue: 0, useNativeDriver: false }).start();
        } else {
          this.anim.setValue(0);
        }
    
        setTimeout(() => {
          if (this.mounted) {
            this.setState({ active: false, resetToken: this.state.resetToken });
          }
        }, 250);
      }
    

    It's working fine !! But the author should consider implementing these changes in the new version.

  8. qiqo commented on Jul 26, 2020

    @qiqo

    there's a pull request to fix this since April, I hope the author is all okay and could merge it for the fix.

  9. mannyhappenings commented on Aug 2, 2020

    @mannyhappenings

    Until the PRs get merged, monkey patching the class works,

    Hope this helps to some people annoyed by that warning

    import RNActionButton from 'react-native-action-button'
    import { Animated } from 'react-native'
    
    RNActionButton.prototype.animateButton = function(animate = true) {
        if (this.state.active) return this.reset();
    
        if (animate) {
          Animated.spring(this.anim, { toValue: 1, useNativeDriver: false }).start();
        } else {
          this.anim.setValue(1);
        }
    
        this.setState({ active: true, resetToken: this.state.resetToken });
    }
    
    RNActionButton.prototype.reset = function (animate = true) {
        if (this.props.onReset) this.props.onReset();
    
        if (animate) {
          Animated.spring(this.anim, { toValue: 0, useNativeDriver: false }).start();
        } else {
          this.anim.setValue(0);
        }
    
        setTimeout(() => {
          if (this.mounted) {
            this.setState({ active: false, resetToken: this.state.resetToken });
          }
        }, 250);
    }
  10. Mazinkam commented on Oct 1, 2020

    @Mazinkam

    How is this "monkey patch" used?

  11. ChronSyn commented on Oct 31, 2020

    @ChronSyn

    How is this "monkey patch" used?

    You paste the code at the top of the file for the component where you're using the action button

  12. manishsharma004 commented on Dec 31, 2020

    @manishsharma004

    How is this "monkey patch" used?

    As @ChronSyn mentioned, you just paste the patch in any file. But since, it sets the prototype for a class, it's better to put it in an separate file as module an load it in some top level component like App so that it gets loaded only once(not that it makes much difference, but it feels better this way to load it). You don't need to put this patch in every file. Also do add a TODO comment to remove this patch once the PRs are merged and you update to the fixed version.

  13. ConstantTime commented on Jan 25, 2021

    @ConstantTime

    I am trying to use this in Typescript but the monkey patch doesn't seem to be working. Any fix that can help in typescript? @mannyhappenings @manishsharma004 @ChronSyn

    Errors being:

    1. Property 'animateButton' does not exist on type 'ActionButton'.
    2. Property 'reset' does not exist on type 'ActionButton'
    3. Property 'mounted' does not exist on type 'ActionButton', etc.
  14. dcjones1 commented on Mar 2, 2021

    @dcjones1

    @ConstantTime Here are some quick and dirty typings:

    
    interface ExtendedButton extends ActionButton {
      anim: Animated.Value;
      animateButton: Function;
      state: {
        active: boolean;
        resetToken: any;
      };
      reset: Function;
      mounted: boolean;
      props: ActionButtonProperties & {onReset: Function};
    }
    (RNActionButton.prototype as ExtendedButton).animateButton = function (animate = true) {
      if (this.state.active) return this.reset();
      if (animate) {
        Animated.spring(this.anim, {toValue: 1, useNativeDriver: false}).start();
      } else {
        this.anim.setValue(1);
      }
      this.setState({active: true, resetToken: this.state.resetToken});
    };
    (RNActionButton.prototype as ExtendedButton).reset = function (animate = true) {
      if (this.props.onReset) this.props.onReset();
      if (animate) {
        Animated.spring(this.anim, {toValue: 0, useNativeDriver: false}).start();
      } else {
        this.anim.setValue(0);
      }
      setTimeout(() => {
        if (this.mounted) {
          this.setState({active: false, resetToken: this.state.resetToken});
        }
      }, 250);
    };
    
  15. phatmann commented on Aug 30, 2021

    @phatmann

    The workaround: disable the warning:

    useEffect(() => {
        LogBox.ignoreLogs(['Animated: `useNativeDriver`']);
    }, [])
    
  16. GustavoContreiras-Feegow commented on Oct 15, 2021

    @GustavoContreiras-Feegow
    1. Run yarn add -D replace-in-files-cli
    2. On package.json, add replacement scripts and postinstall script:
    {
      ...
      "scripts": {
        "replace:actionbutton": "yarn replace:actionbutton:stepone && yarn replace:actionbutton:steptwo && yarn replace:actionbutton:stepone && yarn replace:actionbutton:steptwo",
        "replace:actionbutton:stepone": "yarn replace-in-files --string='Animated.spring(this.anim, { toValue: 1 }' --replacement='Animated.spring(this.anim, { toValue: 1, useNativeDriver: false }' node_modules/react-native-action-button/ActionButton.js",
        "replace:actionbutton:steptwo": "yarn replace-in-files --string='Animated.spring(this.anim, { toValue: 0 }' --replacement='Animated.spring(this.anim, { toValue: 0, useNativeDriver: false }' node_modules/react-native-action-button/ActionButton.js",
        "postinstall": "yarn replace:actionbutton"
      },
      "dependencies": {
        ...
      },
      "devDependencies": {
        "replace-in-files-cli": "^1.0.0"
      }
    }
    
    

    Tip: Do this for any fix in any package you need to fix inside node_modules folder

  17. phatmann commented on Oct 15, 2021

    @phatmann

    @GustavoContreiras-Feegow Thanks for the info. Any reason you are not using patch-package?

  18. added a commit that references this issue on Dec 20, 2021
  19. aglitoiu commented on Apr 7, 2022

    @aglitoiu

    https://www.npmjs.com/package/react-native-action-button-warnings-fixed

    Feel free to try it and create issues there, maybe we will be able to keep it maintained by community, in absence of creator

  20. jhusef-lopez commented on Oct 3, 2022

    @jhusef-lopez

    I think the solution to the problem will be to implement the following change to the ActionButton.js file;

     //////////////////////
      // Animation Methods
      //////////////////////
    
      animateButton(animate = true) {
        if (this.state.active) return this.reset();
    
        if (animate) {
          Animated.spring(this.anim, { toValue: 1, useNativeDriver: false }).start();
        } else {
          this.anim.setValue(1);
        }
    
        this.setState({ active: true, resetToken: this.state.resetToken });
      }
    
      reset(animate = true) {
        if (this.props.onReset) this.props.onReset();
    
        if (animate) {
          Animated.spring(this.anim, { toValue: 0, useNativeDriver: false }).start();
        } else {
          this.anim.setValue(0);
        }
    
        setTimeout(() => {
          if (this.mounted) {
            this.setState({ active: false, resetToken: this.state.resetToken });
          }
        }, 250);
      }
    

    I create a new component:

    import ActionButton from 'react-native-circular-action-menu';
    import { Animated } from 'react-native';
    /**

    • CustomActionButton implementa el uso del componente ActionButton inyectando funciones de correción de errores
      */
      export default class CustomActionButton extends ActionButton {
      animateButton() {
      if (this.state.active) {
      this.reset();
      return;
      }

      Animated.spring(this.state.anim, {
      toValue: 1,
      useNativeDriver: false,
      duration: 250,
      }).start();

      this.setState({ active: true });
      }

    reset() {
    Animated.spring(this.state.anim, {
    toValue: 0,
    useNativeDriver: false,
    duration: 250,
    }).start();

    setTimeout(() => {
      this.setState({ active: false });
    }, 250);
    

    }
    }

    this work to me

  21. warmfire540 commented on Aug 5, 2025

    @warmfire540

    I adjusted this in a fork - I'll accept other PRs as well: https://github.com/curious-cat-consulting/react-native-action-button/releases/tag/2.9.2

    you'd use this version via

    yarn add react-native-action-button@https://github.com/curious-cat-consulting/react-native-action-button#2.9.2

    after removing the old one

    react-native-action-button

    let me know if I broke anything, I'll adjust..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions