ptomasroos / react-native-tab-navigator

A tab bar that switches between scenes, written in JS for cross-platform support
MIT License
2.4k stars 416 forks source link

Warning:componentWillReceiveProps is deprecated #194

Open nameIsYong opened 5 years ago

nameIsYong commented 5 years ago

Warning:componentWillReceiveProps is deprecated and will be removed in the next major version. Use static getDerivedStateFromProps instead. Please update the following components:TabNavigator

$ npm info react-native-tab-navigator react-native-tab-navigator@0.3.4 | MIT | deps: 2 | versions: 24

""" import TabNavigator from "react-native-tab-navigator"; ... render () { return (

{this.createItem(kTitle_home, kIcon_home, kIcon_home_selected, HomeView)} {this.createItem(kTitle_mine, kIcon_mine, kIcon_mine_selected, MineView)}
    )
}

createItem(selectedTab, icon, selectedIcon, Component) { return ( <TabNavigator.Item title = {selectedTab} renderIcon = {() => } selected = {this.state.selectedTab === selectedTab} onPress = {() => this.setState({selectedTab:selectedTab})}

</TabNavigator.Item> ) } """

""" { "name": "Demo", "version": "0.0.1", "private": true, "scripts": { "start": "react-native start", "test": "jest", "lint": "eslint ." }, "dependencies": { "react": "16.8.6", "react-native": "0.60.4", "react-native-tab-navigator": "^0.3.4", "react-navigation": "^3.11.1" }, "devDependencies": { "@babel/core": "^7.5.5", "@babel/runtime": "^7.5.5", "@react-native-community/eslint-config": "^0.0.5", "babel-jest": "^24.8.0", "eslint": "^6.1.0", "jest": "^24.8.0", "metro-react-native-babel-preset": "^0.55.0", "react-test-renderer": "16.8.6" }, "jest": { "preset": "react-native" } }

"""

bohehe commented 5 years ago

this may helps: https://stackoverflow.com/questions/49258598/react-native-lifecycle-methods-warning-componentwillreceiveprops-is-deprecate