したがって、React nativeとRealmを使用しています。基本的には、レルムクエリが開始される前にインジケータを表示し、終了したらインジケータを非表示にします。しかし、指標が現れていないようです。 Reactネイティブの私の理解はまだ新しいです!ここでReactネイティブsetStateは更新されません - 関数内で2回呼び出されます。更新が完了するまで待ちます。
は、私がこれまで持っているものです。
<SegmentedControlIOS
values={['Matched', 'Last Active', 'Distance', 'Age']}
momentary={false}
tintColor={'#DB4C2C'}
style={{
width: width,
marginTop: 10
}}
selectedIndex={this.state.scIndex}
onValueChange={(value) => {}}
onChange={(event) => {
console.log("CHANGE")
var selectedIndex = event.nativeEvent.selectedSegmentIndex;
this.sortMatches(selectedIndex)
this.setState({
scIndex: event.nativeEvent.selectedSegmentIndex
})
}}/>
sortMatches(index) {
this.setState({loading: true})
var sortMatches = null;
if (index == 0) {
sortedMatches = this._sort_matched()
} else if (index == 1) {
sortedMatches = this._sort_last_active()
} else if (index == 3) {
sortedMatches = this._sort_birthdate()
}
let dataSource = ds.cloneWithRows(sortedMatches)
this.setState({dataSource: dataSource, loading: false})
}
<ActivityIndicator
animating={this.state.loading}
style={[styles.centering, {height: 30, paddingTop: 20}]}
size="small"/>
正しい一致が表示されますか? – FuzzyTree