【问题标题】:Warning: SceneView has a method called shouldComponentUpdate()警告:SceneView 有一个名为 shouldComponentUpdate() 的方法
【发布时间】:2017-11-10 12:39:17
【问题描述】:

大家好:我在 react-native 项目中使用 react-native-router-flux (v.3.39.2),但今天它显示了这个警告:

警告:SceneView 有一个名为 shouldComponentUpdate() 的方法。 扩展时不应使用 shouldComponentUpdate React.PureComponent。如果使用 shouldComponentUpdate,请扩展 React.Component。

这是我的入口点:

import React from 'react';
import { AppRegistry, StyleSheet, Platform } from 'react-native';
import { Scene, Router } from 'react-native-router-flux';

import HomeView from './src/components/HomeView'
import ArtistDetailView from './src/components/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"
  }
}

怎么了?

谢谢

【问题讨论】:

    标签: react-native react-native-router-flux


    【解决方案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 install 更改将会消失,但在此之前如果你想摆脱警告,进入 node_modules/react-native-experimental-navigation/NavigationCard.js,然后换行: 类 SceneView 扩展 React.PureComponent { 到 类 SceneView 扩展 React.Component {

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-24
      相关资源
      最近更新 更多