获得 'Invariant Violation: `refreshing` prop must be set as a boolean in order to use `onRefresh`, but got `undefined`'

getting 'Invariant Violation: `refreshing` prop must be set as a boolean in order to use `onRefresh`, but got `undefined`'

当主屏幕加载时我得到 'Invariant Violation: refreshing prop must be set as a boolean in order to use onRefresh, but got undefined' 请帮助。

class Home extends Component {

constructor(props) {
    super(props)

    this.state = {
      suggestionList:[],
      refreshing:false,
    };
}

componentWillReceiveProps(nextProps){

    this.setState({

      suggestionList: nextProps.result.suggestionsArray ,
      lastSuggestionKey : nextProps.result.lastSuggestionKey,
      refreshing : false

    });

}

handleRowPress = (item) => {
  this.props.navigation.navigate('UserDetails', item);
};

handleMoreRequest = () => {
  this.props.getOld(this.state.lastSuggestionKey);
};

handleRefresh = () => {

  this.setState({
    lastSuggestionKey: '',
    refreshing: true
  });

  this.props.getAll();
};

componentWillMount() {

  this.props.getAll();

}

 render() {

  return (
    <View style={styles.containerStyle}>

      <FlatList
        style={{backgroundColor: colors.background}}
        data={this.state.suggestionList}
        renderItem={(item) => 
          <CardItem contact={item.item} 
                    onPress={() => this.handleRowPress(item)}
                    onCommentPress={() => this.props.navigation.navigate('SuggestionList')}/>
        }
        keyExtractor={item => item.suggestionid}
        refeshing={this.state.refreshing}
        onRefresh={() => this.handleRefresh()}
        onEndReached={this.handleMoreRequest}
        onEndReachedThreshold={0.7}
      />

    </View>
  );

  }
   }

const styles = StyleSheet.create({
  containerStyle:{
    flex:1, 
    backgroundColor: colors.background
  },
});

function mapStateToProps({ suggestion }) {
  return { 
    result: suggestion.result,
  };
}

export default connect(mapStateToProps, actions)(Home);

您的 FlatList 属性有错字,应该是 refreshing 而不是 refeshing

我遇到了同样的问题,我只是在 onRefresh 道具之前设置了刷新道具并且它起作用了

`refreshing={refreshing}
    onRefresh={() => {
      setItem(sumItemsArray);
    }}
  />

我也遇到过同样的事情,我发现这个问题是因为 onRefresh 道具的使用必须与 refreshing={condition} 道具的使用重合。