0
私はReact jsを初めて使っています。ユーザーが単語を入力してスペースバーを押すと、新しい単語として配列に格納され、入力ボックスを右 ユーザー入力が何かに反応したときのカスタム入力状態構造の設定j
コード
state = {
showThisValue:"",
storeValue:[] // ["Walk","on","th"]
};
handleInput = e => {
/* Store the value I have no Idea how to do this */
if(e.target.value === " "){
}else {
let updatedValue = this.state.storeValue.length === 0 ? this.state.storeValue.concat(e.target.value) : this.state.storeValue.slice(this.state.storeValue.length - 1).concat(this.state.storeValue[this.state.storeValue.length - 1].concat(e.target.value))
this.setState({
storeValue:updatedValue
})
}
};
ロジック
let updatedValue = this.state.storeValue.length === 0 ? this.state.storeValue.concat(e.target.value) : this.state.storeValue.slice(this.state.storeValue.length - 1).concat(this.state.storeValue[this.state.storeValue.length - 1].concat(e.target.value))
しかし、上記のコードは何かリクを返します。..クリアされますeこのように個別の手紙のように
["w","a","l","k"]
あなたが誰かがあなたのために全体のコードを書いてみませんか? – moon
ちょっと待ってくださいコードを更新してください – Nane
更新が終わったらコメントを残してください。通知が届きます – moon