Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useNativeDriver #105

Open
sachithamh opened this issue Apr 14, 2020 · 11 comments · Fixed by RodolfoGS/react-native-actionsheet#1
Open

useNativeDriver #105

sachithamh opened this issue Apr 14, 2020 · 11 comments · Fixed by RodolfoGS/react-native-actionsheet#1

Comments

@sachithamh
Copy link

sachithamh commented Apr 14, 2020

Animated: useNativeDriver was not specified. This is a required option and must be explicitly set to true or false
in ActionSheet (at SignUp_1.tsx:107)
in SignUp_Name (at SceneView.tsx:98)
in SceneView (at useDescriptors.tsx:125)
in CardContainer (at CardStack.tsx:531)
in CardStack (at StackView.tsx:420)
in KeyboardManager (at StackView.tsx:418)
in Context.Consumer (at StackView.tsx:416)
in StackView (at createStackNavigator.tsx:67)
in StackNavigator (at navigation/​index.tsx:27)
in LoginStackScreen (at SceneView.tsx:98)
in SceneView (at useDescriptors.tsx:125)
in CardContainer (at CardStack.tsx:531)
in CardStack (at StackView.tsx:420)
in KeyboardManager (at StackView.tsx:418)
in Context.Consumer (at StackView.tsx:416)
in StackView (at createStackNavigator.tsx:67)
in StackNavigator (at navigation/​index.tsx:184)
in MainStackScreen (at navigation/​index.tsx:215)
in AppNavigation (at App.tsx:27)
in App (at renderApplication.js:45)

react native 0.62

@asasouza
Copy link

+1 same problem...

@silviaportelaf
Copy link

same problem here

@tuxlan
Copy link

tuxlan commented May 17, 2020

also same problem here :/

@asasouza
Copy link

For those with this problem the resolution is simple, edit the functions _showSheet and _hideSheet, that use Animated API, in ActionSheetCustom.js to include the option useNativeDriver: true.
A simple workaround to persist this change in future npm install executions is use patch-package.

@pke
Copy link

pke commented Jun 3, 2020

@asasouza you don't happen to have the patch file to use? ;)
How do you usually create those patch files?

@asasouza
Copy link

asasouza commented Jun 3, 2020

@pke This is the patch file:

index 7a0fc35..d409f70 100644
--- a/node_modules/react-native-actionsheet/lib/ActionSheetCustom.js
+++ b/node_modules/react-native-actionsheet/lib/ActionSheetCustom.js
@@ -24,8 +24,9 @@ class ActionSheet extends React.Component {
     }
   }
 
   get styles () {
@@ -68,14 +69,16 @@ class ActionSheet extends React.Component {
     Animated.timing(this.state.sheetAnim, {
       toValue: 0,
       duration: 250,
-      easing: Easing.out(Easing.ease)
+      easing: Easing.out(Easing.ease),
+      useNativeDriver: true,
     }).start()
   }
 
   _hideSheet (callback) {
     Animated.timing(this.state.sheetAnim, {
       toValue: this.translateY,
-      duration: 200
+      duration: 200,
+      useNativeDriver: true,
     }).start(callback)
   }

I created it by using the package patch-package, available in npm.
All you need to do is install the patch-package in you project, or globally, and add in the postinstall script in your package.json npx patch-package. After this, just edit the ActionSheetCustom.js and run npx patch-package react-native-actionsheet and done, it will create a folder with the package and every npm install execution will trigger the postinstall that applies the changes;
Sorry if my explanation is not enough, english is not my primary language. If you still have doubts I strongly recommend the docs from the package;

@pke
Copy link

pke commented Jun 3, 2020

Thanks, explanation is fine @asasouza! And thanks for the patch file. Next time I'll try it myself.

There should be a way to attach such path files as temp fixes to issues here in GH :)

@pke
Copy link

pke commented Jun 3, 2020

@asasouza any idea how we could use https://patch-diff.githubusercontent.com/raw/beefe/react-native-actionsheet/pull/88.patch for patch-package? It says "unrecognised patch file" when I drop it into the patches folder.

@litinskii
Copy link

Same problem

@aprilmintacpineda
Copy link

aprilmintacpineda commented Sep 28, 2020

Yeah, I got this error as well, just use patch-package,

Install

npm i -S patch-package

Then add

"script": {
  // ... other scripts
  "postinstall": "patch-package" // <--- add this line
}

to your package.json.

Edit file

Go to node_modules/react-native-actionsheet/lib/ActionSheetCustom.js

Replace the _hideSheet on like 76 with the following:

_hideSheet (callback) {
  Animated.timing(this.state.sheetAnim, {
    toValue: this.translateY,
    duration: 200,
    useNativeDriver: true
  }).start(callback)
}

also the _showSheet on line 67 with the following:

_showSheet = () => {
  Animated.timing(this.state.sheetAnim, {
    toValue: 0,
    duration: 250,
    easing: Easing.out(Easing.ease),
    useNativeDriver: true
  }).start()
}

Bonus

On render method, on the <Modal> render, change the animationType="none" to animationType="fade", this will gracefully open the modal instead of it popping right away.

patch it up

run npx patch-package

Then you're all set.

@alessiocancian
Copy link

I released the fix to npm, read #131

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants