React native 0.60.4 componentWillReceiveProps componentWillUpdate Remove
See original GitHub issueWhich OS ?
macOS Mojave 10.14.6
Version
Which versions are you using:
- react-native-swiper ^1.5.14
- react-native 0.60.4
Actual behaviour
I wrote an example:
import React, { Component } from "react";
import {
Text,
View,
Image,
Dimensions
} from "react-native";
import Swiper from 'react-native-swiper'
const { width } = Dimensions.get('window');
class IndexScreen extends Component {
constructor (props) {
super(props);
this.state = {
imgList: [
'https://img04.sogoucdn.com/app/a/100520021/3ea2745207ce5c390280e5d5245451e9',
'https://img01.sogoucdn.com/app/a/100520021/8e6ef3612bee7623f5d42e2e88c7b4cb',
'https://img04.sogoucdn.com/app/a/100520021/26dffdc1ba9adcd3a0bfdb8728f22b9f',
'https://img04.sogoucdn.com/app/a/100520021/3d23c68fbbcf51e9e297f505e33cdf5e'
],
};
}
render() {
return (
<View style={{flex: 1}}>
<Swiper loadMinimal loadMinimalSize={1} style={styles.wrapper} loop={true}>
{
this.state.imgList.map((item, i) => {
return <Image key={i} style={styles.image} source={{uri: item}} />
})
}
</Swiper>
<View>
<Text>asd</Text>
</View>
</View>
);
}
}
const styles = {
wrapper: {
height: 200,
},
slide: {
flex: 1,
justifyContent: 'center',
backgroundColor: 'transparent'
},
image: {
width: width,
flex: 1,
backgroundColor: 'transparent'
},
};
export default IndexScreen;
It reported me two warnings
Warning: componentWillReceiveProps is deprecated and will be removed in the next major version. Use static getDerivedStateFromProps instead.
Warning: componentWillUpdate is deprecated and will be removed in the next major version. Use componentDidUpdate instead. As a temporary workaround, you can rename to UNSAFE_componentWillUpdate.
I am sure that my code does not use the two lifecycle functions that react is about to remove, but I don’t know how it should be fixed.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:13
- Comments:9
Top Results From Across the Web
Getting warning: "componentWillUpdate is deprecated and ...
I am facing a very strange issue while developing a react native app. ... componentWillUpdate is deprecated and will be removed in the...
Read more >React17, or how to get rid of “componentWillReceiveProps”?
componentWillUpdate () is invoked just before rendering when new props or state are being received. Use this as an opportunity to perform ...
Read more >React Native Application Lifecycle Methods explained
2. Updating methods · 2. Updating methods · 1. componentWillReceiveProps(): · 2. shouldComponentUpdate(): · 3. componentWillUpdate(): · 4. componentDidUpdate(): ...
Read more >How to improve the performance of a React Native app
It is available for the Android platform for React Native version 0.60.4 and above. It is also available for iOS from version 0.64-rc.0...
Read more >Want To Optimize React Native Performance? The Dos And Don'ts ...
Hermes is available for the Android platform since React Native version 0.60.4. The benefit of using it is that it reduces the download...
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
Any plans for a new release?
Actually, that issue not related to OS. The problem is that lib uses
componentWillReceiveProps
andcomponentWillUpdate
which will be removed from 17 version of React. So would be really great if lib’s maintainers made a migration to a new lifecycle hooks.