2017-06-28 44 views
0

我開始使用React Native。我按照建議遵循指令:React-Native:propTypes和createClass已棄用

react-native init myProject。因此,爲了測試正在運行的應用程序,我使用了遠程JS調試來檢查一切是否正常。

然後我看到propTypes和createClass已被棄用。

我不知道如何將其遷移到新版本。 (該指令的反應,沒有反應過來本土的,我沒有使用createClass但例如擴展組件)

enter image description here

這裏是我的依賴關係: 「反應」:「16.0.0-alpha.12 」 「反應原生」: 「0.45.1」,

這裏是我的代碼:

'use strict'; 

import React, { Component } from 'react'; 
import { 
    AppRegistry, 
    StyleSheet, 
    Text, 
    View 
} from 'react-native'; 

export default class myProject extends Component { 

    render() { 
    return (
     <View > 
     <Text > 
      Welcome to React Native! 
     </Text> 
     <Text > 
      To get started, edit index.android.js 
     </Text> 
     <Text > 
      Double tap R on your keyboard to reload,{'\n'} 
      Shake or press menu button for dev menu 
     </Text> 
     </View> 
    ); 
    } 
} 

const styles = StyleSheet.create({ 
    container: { 
    flex: 1, 
    justifyContent: 'center', 
    alignItems: 'center', 
    backgroundColor: '#F5FCFF', 
    }, 
    welcome: { 
    fontSize: 20, 
    textAlign: 'center', 
    margin: 10, 
    }, 
    instructions: { 
    textAlign: 'center', 
    color: '#333333', 
    marginBottom: 5, 
    }, 
}); 

AppRegistry.registerComponent('myProject',() => myProject); 

回答

0

對於道具類型,您現在應該使用道具類型包:
https://github.com/facebook/prop-types

對於createClass你現在應該使用create-反應級包: https://www.npmjs.com/package/create-react-class

瞭解更多關於它here。 「

+0

」我不知道如何將它遷移到新版本中(說明是針對React而不是React Native的,我沒有使用createClass,但擴展了Component)「 – Erased

+0

反應本機。反應原生基本上與不同組分反應。雖然相同的語法.. –

+0

那麼,但爲什麼createClass?我沒有使用它,我使用擴展組件爲react-native和react-native項目的基本代碼,道具還沒有使用 – Erased