React Nativeの条件に基づいて要素をレンダリングするにはどうすればよいですか?
これは私が試した方法です:
render() {
return (
<Text>amount is: {this.state.amount}</Text> // it correctly prints amount value
</Button>
{this.state.amount} >= 85 ? <button>FIRST</button> : <button>SECOND</button>
<Text>some text</Text>
);
}
ただし、次のエラーメッセージが表示されます。
Expected a component class, got [object Object]
あなたはあなたの置き忘れました}
:
render() {
return (
<Text>amount is: {this.state.amount}</Text>
{this.state.amount >= 85 ? <button>FIRST</button> : <button>SECOND</button>}
<Text>some text</Text>
);
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加