Warning: componentWillRecieveProps is deprecated
See original GitHub issueGetting a warning:
componentWillRecieveProps is deprecated and will be removed in the next major version use Static getDerivedStatefromProps instead
Is anyone else getting this error?
Code:
import React, { Component } from "react";
import { View, Text, TouchableOpacity, Button } from "react-native";
import { tabStyles } from "../../stylesheet/basicStyles";
import buttonText from '../../assests/res/strings'
import Modal from "react-native-modal";
import modalString from '../../assests/res/strings'
class ButtonsComponent extends Component {
state = {
visibleModalId: null,
};
renderModalContentOne = () => (
<View style={tabStyles.content}>
<Text style={tabStyles.contentTitle}>{modalString.modalText.modalOne}</Text>
<Button
onPress={() => this.setState({ visibleModal: null })}
style = {tabStyles.modalButtonStyle}
title="Close"
/>
</View>
);
renderModalContentTwo = () => (
<View style={tabStyles.content}>
<Text style={tabStyles.contentTitle}>{modalString.modalText.modalTwo}</Text>
<Button
onPress={() => this.setState({ visibleModal: null })}
style = {tabStyles.modalButtonStyle}
title="Close"
/>
</View>
);
renderModalContentThree = () => (
<View style={tabStyles.content}>
<Text style={tabStyles.contentTitle}>{modalString.modalText.modalThree}</Text>
<Button
onPress={() => this.setState({ visibleModal: null })}
style = {tabStyles.modalButtonStyle}
title="Close"
/>
</View>
);
renderModalContentFour = () => (
<View style={tabStyles.content}>
<Text style={tabStyles.contentTitle}>{modalString.modalText.modalFour}</Text>
<Button
onPress={() => this.setState({ visibleModal: null })}
style = {tabStyles.modalButtonStyle}
title="Close"
/>
</View>
);
render() {
return (
<View style={tabStyles.buttonView}>
<TouchableOpacity onPress={() => this.setState({ visibleModal: 'buttonOne' })} >
<View style={tabStyles.button}>
<Text style={tabStyles.buttonText}>{buttonText.homeText.buttonOne}</Text>
</View>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.setState({ visibleModal: 'buttonTwo' })}>
<View style={tabStyles.button}>
<Text style={tabStyles.buttonText}>{buttonText.homeText.buttonTwo}</Text>
</View>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.setState({ visibleModal: 'buttonThree' })}>
<View style={tabStyles.button}>
<Text style={tabStyles.buttonText}>{buttonText.homeText.buttonThree}</Text>
</View>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.setState({ visibleModal: 'buttonFour' })}>
<View style={tabStyles.button}>
<Text style={tabStyles.buttonText}>{buttonText.homeText.buttonFour}</Text>
</View>
</TouchableOpacity>
<Modal isVisible={this.state.visibleModal === 'buttonOne'}>
{this.renderModalContentOne()}
</Modal>
<Modal isVisible={this.state.visibleModal === 'buttonTwo'}>
{this.renderModalContentTwo()}
</Modal>
<Modal isVisible={this.state.visibleModal === 'buttonThree'}>
{this.renderModalContentThree()}
</Modal>
<Modal isVisible={this.state.visibleModal === 'buttonFour'}>
{this.renderModalContentFour()}
</Modal>
</View>
)
}
}
export default ButtonsComponent;
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (5 by maintainers)
Top Results From Across the Web
Warning: componentWillRecieveProps is deprecated #299
Getting a warning: componentWillRecieveProps is deprecated and will be removed in the next major version use Static getDerivedStatefromProps ...
Read more >reactjs - why is componentWillReceiveProps deprecated?
Thus, componentWillReceiveProps is being deprecated in favor of the following reason: Use getDerivedStateFromProps; Or, use componentDidUpdate.
Read more >React17, or how to get rid of “componentWillReceiveProps”?
As you may already know, with the release of React 16.3, some of legacy lifecycles were deprecated. One of the biggest lessons we've...
Read more >React: componentWillMount to be deprecated! - Northcoders
A significant change in React v16.3.0 is the deprecation of several methods. These are: componentWillMount. componentWillRecieveProps. componentWillUpdate.
Read more >Warning componentwillmount is Deprecated and will be ...
Warning componentwillmount is Deprecated and will be Removed in the Next Major Version in React Native Solved.The above lifecycle methods ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is being fixed with an open PR: https://github.com/oblador/react-native-animatable/pull/280
Same here. I got this. The warning seems from the “withAnimatable”