Skip to content

UNSAFE_componentWillMount and useNativeDriver #133

@Timmyy3000

Description

@Timmyy3000

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch react-native-swipeable@0.6.0 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-swipeable/lib/index.js b/node_modules/react-native-swipeable/lib/index.js
index 57996ad..6016756 100644
--- a/node_modules/react-native-swipeable/lib/index.js
+++ b/node_modules/react-native-swipeable/lib/index.js
@@ -78,7 +78,7 @@ var Swipeable = function (_PureComponent) {
     }, _this._unmounted = false, _this._handlePan = _reactNative.Animated.event([null, {
       dx: _this.state.pan.x,
       dy: _this.state.pan.y
-    }]), _this._handleMoveShouldSetPanResponder = function (event, gestureState) {
+    }], {useNativeDriver: true}), _this._handleMoveShouldSetPanResponder = function (event, gestureState) {
       return Math.abs(gestureState.dx) > _this.props.swipeStartMinDistance;
     }, _this._handlePanResponderStart = function (event, gestureState) {
       var _this$state = _this.state,
@@ -294,8 +294,8 @@ var Swipeable = function (_PureComponent) {
   }
 
   _createClass(Swipeable, [{
-    key: 'componentWillMount',
-    value: function componentWillMount() {
+    key: 'UNSAFE_componentWillMount',
+    value: function UNSAFE_componentWillMount() {
       var _props = this.props,
           onPanAnimatedValueRef = _props.onPanAnimatedValueRef,
           onRef = _props.onRef;
@@ -422,7 +422,8 @@ var Swipeable = function (_PureComponent) {
           toValue: {
             x: leftButtons.length * leftButtonWidth,
             y: 0
-          }
+          },
+          useNativeDriver: true
         }, leftButtonsOpenReleaseAnimationConfig);
       }
 
@@ -431,7 +432,8 @@ var Swipeable = function (_PureComponent) {
           toValue: {
             x: rightButtons.length * rightButtonWidth * -1,
             y: 0
-          }
+          },
+          useNativeDriver: true
         }, rightButtonsOpenReleaseAnimationConfig);
       }
 
@@ -671,7 +673,8 @@ Swipeable.defaultProps = {
   swipeReleaseAnimationConfig: {
     toValue: { x: 0, y: 0 },
     duration: 250,
-    easing: _reactNative.Easing.elastic(0.5)
+    easing: _reactNative.Easing.elastic(0.5),
+    useNativeDriver: true
   },
 
   // misc

This issue body was partially generated by patch-package.

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