Skip to content

Instantly share code, notes, and snippets.

@OscarYuen
Last active May 25, 2021 04:48
Show Gist options
  • Save OscarYuen/21f2f8d5c133caef7d31475cfec2d5b0 to your computer and use it in GitHub Desktop.
Save OscarYuen/21f2f8d5c133caef7d31475cfec2d5b0 to your computer and use it in GitHub Desktop.
patch file for react-native-material-dropdown in react-native 0.62

Fix:

  1. Fix useNativeDrive warning
  2. Fix app crash on open error(n4kz/react-native-material-dropdown#224)

Requirement:

  1. Install patch-package
  2. Run yarn add patch-package postinstall-postinstall or npm i patch-package
  3. Your react-native-material-textfield dependency must be installed under react-native-material-dropdown node_modules folder. If not, please use the patch from this thread instead(n4kz/react-native-material-textfield#249)

Instruction:

  1. Create "patches" directory under your project's root
  2. Copy this patch to patches/react-native-material-dropdown++react-native-material-textfield+0.12.0.patch
  3. Run yarn patch-package or npx patch-package
  4. Fix is already applied. Add the following to package.json to make sure the fix is automatically applied next time:
 "scripts": {
    "postinstall": "patch-package"
 }
diff --git a/node_modules/react-native-material-dropdown/node_modules/react-native-material-textfield/src/components/affix/index.js b/node_modules/react-native-material-dropdown/node_modules/react-native-material-textfield/src/components/affix/index.js
index d6c9d64..fe33c27 100644
--- a/node_modules/react-native-material-dropdown/node_modules/react-native-material-textfield/src/components/affix/index.js
+++ b/node_modules/react-native-material-dropdown/node_modules/react-native-material-textfield/src/components/affix/index.js
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types';
import React, { PureComponent } from 'react';
-import { Animated } from 'react-native';
+import { Animated, Text } from 'react-native';
import styles from './styles';
@@ -24,7 +24,7 @@ export default class Affix extends PureComponent {
baseColor: PropTypes.string.isRequired,
animationDuration: PropTypes.number.isRequired,
- style: Animated.Text.propTypes.style,
+ style: Text.propType,
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
@@ -51,6 +51,7 @@ export default class Affix extends PureComponent {
.timing(opacity, {
toValue: (props.active || props.focused)? 1 : 0,
duration: animationDuration,
+ useNativeDriver: true,
})
.start();
}
diff --git a/node_modules/react-native-material-dropdown/node_modules/react-native-material-textfield/src/components/field/index.js b/node_modules/react-native-material-dropdown/node_modules/react-native-material-textfield/src/components/field/index.js
index 52c1868..c7f4658 100644
--- a/node_modules/react-native-material-dropdown/node_modules/react-native-material-textfield/src/components/field/index.js
+++ b/node_modules/react-native-material-dropdown/node_modules/react-native-material-textfield/src/components/field/index.js
@@ -157,7 +157,7 @@ export default class TextField extends PureComponent {
let toValue = this.focusState(props.error, state.focused);
Animated
- .timing(focus, { toValue, duration })
+ .timing(focus, { toValue, duration, useNativeDriver: true, })
.start(this.onFocusAnimationEnd);
}
}
diff --git a/node_modules/react-native-material-dropdown/node_modules/react-native-material-textfield/src/components/helper/index.js b/node_modules/react-native-material-dropdown/node_modules/react-native-material-textfield/src/components/helper/index.js
index 60184ea..362a81d 100644
--- a/node_modules/react-native-material-dropdown/node_modules/react-native-material-textfield/src/components/helper/index.js
+++ b/node_modules/react-native-material-dropdown/node_modules/react-native-material-textfield/src/components/helper/index.js
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types';
import React, { PureComponent } from 'react';
-import { View, Animated } from 'react-native';
+import { View, Animated, Text } from 'react-native';
import styles from './styles';
@@ -10,7 +10,7 @@ export default class Helper extends PureComponent {
};
static propTypes = {
- style: Animated.Text.propTypes.style,
+ style: Text.propType,
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node,
diff --git a/node_modules/react-native-material-dropdown/node_modules/react-native-material-textfield/src/components/label/index.js b/node_modules/react-native-material-dropdown/node_modules/react-native-material-textfield/src/components/label/index.js
index ac3ed53..66fdbaf 100644
--- a/node_modules/react-native-material-dropdown/node_modules/react-native-material-textfield/src/components/label/index.js
+++ b/node_modules/react-native-material-dropdown/node_modules/react-native-material-textfield/src/components/label/index.js
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types';
import React, { PureComponent } from 'react';
-import { Animated } from 'react-native';
+import { Animated, Text } from 'react-native';
export default class Label extends PureComponent {
static defaultProps = {
@@ -29,7 +29,7 @@ export default class Label extends PureComponent {
animationDuration: PropTypes.number.isRequired,
- style: Animated.Text.propTypes.style,
+ style: Text.propType,
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
@@ -54,7 +54,7 @@ export default class Label extends PureComponent {
let toValue = this.inputState(props);
Animated
- .timing(input, { toValue, duration })
+ .timing(input, { toValue, duration, useNativeDriver: false, })
.start();
}
@@ -62,7 +62,7 @@ export default class Label extends PureComponent {
let toValue = this.focusState(props);
Animated
- .timing(focus, { toValue, duration })
+ .timing(focus, { toValue, duration, useNativeDriver: false, })
.start();
}
}
@Akshay-Katariya
Copy link

Akshay-Katariya commented May 11, 2021

I’m facing the following issue the path is not working for me ☹️

yarn patch-package
yarn run v1.22.5
$ /Users/akshay/ReactProjects/----/node_modules/.bin/patch-package
patch-package 6.4.7
Applying patches...
Error: Patch file found for package react-native-material-textfield which is not present at node_modules/react-native-material-dropdown/node_modules/react-native-material-textfield
---
patch-package finished with 1 error(s).
✨  Done in 0.72s.``

@cinnabarcaracal
Copy link

thank-you, I was not aware you could patch dependencies in a nested fashion like this. This will give us time to identify a more permanent solution

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