私は警告を受けていますEach child in an array or iterator should have a unique "key" prop. Check the render method of Login
無効/回避策キー要求に反応しますか?
キーを使用せずに要素の配列を戻したいと思います。私は無意味なラッパーを追加せずに、このための回避策があると考えなければなりませんか?
注
return [<div/>, <div/>];
render() {
return (
<div className='login'>
{this.mobileWeb()}
{this.pcWeb()}
</div>
);
}
mobileWeb() {
if (this.state.isMobileWeb === true) {
return [
<div className='sky-container'></div>,
<div className='sea-container'></div>
];
}
}
pcWeb() {
if (this.state.isMobileWeb !== true) {
return [
<div className='sky-container'></div>,
<div className='sea-container'>
<LoginForm onChange={this.onChange} ref='loginForm' onEmailChange={this.onEmailChange} onPasswordChange={this.onPasswordChange} />
<input type='submit' value='Submit' onClick={this.login} />
</div>
];
}
}
リアクションキーを無効にすることができないかどうかわかりませんが、状態の変更やDOMのレンダリングを処理することは本当に重要です。https://facebook.github.io/react/docs/reconciliation.html#recursing-on-children – mfrachet