私はエラーがあり、実際になぜそれがわかりません。これは、テストのためにverry簡単なコードジュストがネイティブ反応だ量をインクリメントするボタンとし、UNE他のクラスを呼び出すクラスを作成したい:React Native JS:コンポーネントクラスが必要です。[オブジェクトオブジェクト]
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
TouchableHighlight,
Text,
View
} from 'react-native';
export default class Apprentissage1 extends Component {
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcolm bitch
</Text>
<Product name="Product 1"/>
<Product name="Product 2"/>
</View>
);
}
}
class Product extends Component {
constructor(props) { //Constructeur
super(props);
this.state = {
quantity: 0
};
}
addToCart(){
this.setState({
quantity: this.state.quantity + 1
})
}
render(){
return(
<View style={styles.container}>
<h2>{this.props.name}</h2>
<p>Quantity: {this.state.quantity}</p>
<TouchableHighlight onPress={this.addToCart.bind(this)}>
Add To cart
</TouchableHighlight>
</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('Apprentissage1',() => Apprentissage1);
感謝のあなたの助けのために:)
あなたはWebViewのコンポーネントを使用せずに反応し、ネイティブアプリでHTMLをレンダリングカント...このエラーは、お使いの製品のコンポーネント – Maxwelll
でレンダリング機能に関連しているが、 ''から '' '輸出default'''を削除してみてください'デフォルトのクラスをエクスポートするApprentissage1はコンポーネント{' ''を拡張し、htmlコンポーネントを '' '' ' –