Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

95
Views
Warning: componentWillReceiveProps is depreciated, need to find an alternative for this lifecycle method

This is my interface

    interface FloatingLabelState {
        paddingAnim: Animated.Value;
        opacityAnim: Animated.Value;
        useNativeDriver :boolean;
    }

This is my componentWillReceiveProps function

componentWillReceiveProps(newProps: FloatingLabelProps) {
        Animated.timing(this.state.paddingAnim, {
            toValue: newProps.visible ? 5 : 9,
            duration: 230,
            useNativeDriver:this.state.useNativeDriver
        }).start();
        return Animated.timing(this.state.opacityAnim, {
            toValue: newProps.visible ? 1 : 0,
            duration: 230,
            useNativeDriver:this.state.useNativeDriver
        }).start();
    }

With many resources, came to know that static getDerivedStateFromProps() would be an alternative, Can someone help me convert componentWillReceiveProps to getDerivedStateFromProps method.

7 months ago ยท Juan Pablo Isaza
Answer question
Find remote jobs