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.

React native 0.60.4 componentWillReceiveProps componentWillUpdate Remove

See original GitHub issue

Which 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:open
  • Created 4 years ago
  • Reactions:13
  • Comments:9

github_iconTop GitHub Comments

8reactions
moaycommented, Dec 20, 2019

Any plans for a new release?

6reactions
lhreskacommented, Sep 24, 2019

i have the same issue with you, i have an suggest that how about ignore the warn and test on another phone with another version OS ?

Actually, that issue not related to OS. The problem is that lib uses componentWillReceiveProps and componentWillUpdate 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.

Read more comments on GitHub >

github_iconTop 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 >

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