question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

componentWillReceiveProps is deprecated and will be removed in the next major version of RN

See original GitHub issue

Feature Request

Use static getDerivedStateFromProps instead of componentWillReceiveProps.

Why it is needed

componentWillReceiveProps is deprecated and will be removed in the next major version of React Native.

Possible implementation

Replace the function.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:24
  • Comments:10

github_iconTop GitHub Comments

7reactions
ankorGHcommented, Sep 9, 2020

@andraderaul #141 is not released. Sharing my current solution till it is released. 1.

yarn add patch-package postinstall-postinstall
  1. Update package.json
 "scripts": {
  "postinstall": "patch-package"
 }
  1. Create a folder called patches and inside it create a file called react-native-text-input-mask+2.0.0.patch
  2. Place the code below
diff --git a/node_modules/react-native-text-input-mask/index.js b/node_modules/react-native-text-input-mask/index.js
index 408edad..93388e9 100644
--- a/node_modules/react-native-text-input-mask/index.js
+++ b/node_modules/react-native-text-input-mask/index.js
@@ -34,15 +34,15 @@ export default class TextInputMask extends Component {
     }
   }
 
-  componentWillReceiveProps(nextProps) {
-    if (nextProps.mask && (this.props.value !== nextProps.value)) {
-      mask(this.props.mask, '' + nextProps.value, text =>
+  componentDidUpdate(prevProps) {
+    if (this.props.mask && (prevProps.value !== this.props.value)) {
+      mask(prevProps.mask, '' + this.props.value, text =>
       this.input && this.input.setNativeProps({ text })
       );
     }
 
-    if (this.props.mask !== nextProps.mask) {
-      setMask(findNodeHandle(this.input), nextProps.mask)
+    if (prevProps.mask !== this.props.mask) {
+      setMask(findNodeHandle(this.input), this.props.mask)
     }
   }
  1. run yarn
2reactions
iagormoraescommented, Aug 10, 2020

@iagormoraes can you please mention it here, if you have finished the merge request 142 and when it will be released

I updated the merge conflict on #142, for the temporary fix use my branch as package source on package.json:

"react-native-text-input-mask": "https://github.com/iagormoraes/react-native-text-input-mask"

EDIT: it seems #141 was merged with the fixes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

remote debugging - React-native lifecycle methods warning ...
Warning : componentWillReceiveProps is deprecated and will be removed in the next major version. Use static getDerivedStateFromProps instead.
Read more >
componentWillMount is deprecated and will be removed ...
componentWillMount is deprecated and will be removed in the next major version 0.54.0 in React Native · componentWillMount is deprecated and will be...
Read more >
componentwillmount has been renamed - You.com | The search ...
componentWillMount is deprecated and will be removed in the next major version 0.54.0 in React Native. Asked Mar 10, 2018 • 38 votes...
Read more >
componentWillReceiveProps is deprecated and will be removed in ...
componentWillReceiveProps is deprecated and will be removed in the next major version of RN.
Read more >
مدیاویکی:Gadget-experimental-react.js - ویکی‌پدیا، دانشنامهٔ آزاد
Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?'); }...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found