通过every+return false、some+return true来实现终止循环;提升性能
selectScrollAppSources = key => {
if (this.props.SourceReducer.sourceList) {
this.props.SourceReducer.sourceList.every(item => {
if (item.key === key) {
this.props.setCurSource(item);
return false;
}
});
}
};
selectScrollAppSources = key => {
if (this.props.SourceReducer.sourceList) {
this.props.SourceReducer.sourceList.some(item => {
if (item.key === key) {
this.props.setCurSource(item);
return true;
}
});
}
};