js
1 handleChange = (search) => this.setState({search},this.handleSearch) 2 3 handleSearch = () => { 4 this.setState({searchReference:'1'}) 5 const self = this 6 firebase.database().ref('/users/').orderByChild('user').startAt(self.state.search).endAt(self.state.search + "\uf8ff").once("value",function(snapshot) { 7 const search_users =[] 8 snapshot.forEach(function(childSnapshot) { 9 search_users.push(childSnapshot.val()) 10 }) 11 self.setState({ 12 search_users:search_users, 13 }) 14 }) 15 }
js
1{ 2 (this.searchReference==='1') 3 ?<Content><Text>true</Text></Content> 4 :<Content><Text>false</Text></Content> 5}
このようにreactjsでは完全に再描画されるはずのコードなのですが、なぜかこれではうまくいきません。なぜでしょう。
handleChangeのsetStateでのコールバックとしてhandleSearchしているのは、TextInputのpropsをいじって、onEndEditingやonBlurなどを使用して見たのですが、再描画されずに困ってしまってやってしまっているだけなので、突っ込まないでください。
ちなみに、TextInputでテキストの変更が終了した時に、handleSearchを呼び出すなら、```
onEndEditing={this.handleSearch}
ですよね?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/01/30 04:53
2018/01/30 07:07
2018/01/30 12:25
2018/01/31 00:42
2018/01/31 13:45