拉刷新在本机反应中不起作用

时间:2020-03-13 21:22:02

标签: reactjs react-native

我想尝试在react native中刷新。

我找到了这个例子,但我没有为我工作;遗漏了一些东西,谁能帮我

import { ScrollView, RefreshControl } from 'react-native';

class RefreshableList extends Component {
  constructor(props) {
    super(props);
    this.state = {
      refreshing: false,
    };
  }

  _onRefresh = () => {
    this.setState({refreshing: true});
    fetchData().then(() => {
      this.setState({refreshing: false});
    });
  }

  render() {
    return (
      <ScrollView
        refreshControl={
          <RefreshControl
            refreshing={this.state.refreshing}
            onRefresh={this._onRefresh}
          />
        }
      />
    );
  }
}

0 个答案:

没有答案