大家好:我在react-native项目中使用react-native-router-flux(v.3.39.2),但今天它显示了这个警告:
警告:SceneView有一个名为shouldComponentUpdate()的方法 . 扩展React.PureComponent时,不应使用shouldComponentUpdate . 如果使用了shouldComponentUpdate,请扩展React.Component .
这是我的切入点:
从'react'导入React;从'react-native'导入{AppRegistry,StyleSheet,Platform};
从'react-native-router-flux'导入{Scene,Router};
从'./src/components/HomeView'导入HomeView从'./src/components/ArtistDetailView'导入ArtistDetailView
export default class platzimusic extends React.Component {render(){
const isAndroid = Platform.OS === 'android'
return (
<Router>
<Scene key="root">
<Scene key="home" component={HomeView} hideNavBar/>
<Scene key="artistDetail" component={ArtistDetailView} hideNavBar={isAndroid}/>
</Scene>
</Router>
)
}}
AppRegistry.registerComponent('platzimusic',()=> platzimusic);
这是我的package.json:
{
"name": "platzimusic",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.0.0-alpha.12",
"react-native": "^0.45.0",
"react-native-router-flux": "^3.39.2",
"react-native-vector-icons": "^4.2.0"
},
"devDependencies": {
"babel-jest": "20.0.3",
"babel-preset-react-native": "1.9.2",
"jest": "20.0.4",
"react-test-renderer": "16.0.0-alpha.12"
},
"jest": {
"preset": "react-native"
}
}
怎么了?
谢谢
1 回答
问题已修复:https://github.com/aksonov/react-native-experimental-navigation/pull/23(实际更改可在提交时找到,https://github.com/aksonov/react-native-experimental-navigation/pull/23/files)
我不确定如何更新package.json文件以正确解决问题,因为我很确定如果你安装npm,更改将会消失,但在此之前,如果你想摆脱警告,请进入node_modules /react-native-experimental-navigation/NavigationCard.js,并且变换行:class SceneView将React.PureComponent {扩展到类SceneView扩展了React.Component {