Так что я использую React native и Realm. В основном я хочу показать индикатор перед запуском запроса Realm, а затем скрыть его, когда он будет завершен. Но индикатор, похоже, не появляется. Мое понимание React native по-прежнему новинка!React Native setState не обновляется - вызывается дважды в функции. Подождите, пока не закончите обновление
Вот то, что я до сих пор:
<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