React-Native:FlatList onRefresh没有调用pull up.
发布时间:2020-12-15 20:32:10 所属栏目:百科 来源:网络整理
导读:目前的行为: 我试图通过拉起视图来更新从服务器获取的列表.当我这样做onRefresh不会开火. 我已经在setState函数的回调中设置了GET请求,但这似乎没有做任何事情. 预期行为: 拉起视图调用onRefresh函数. 码: ... constructor(props) { super(props); this.s
目前的行为:
我试图通过拉起视图来更新从服务器获取的列表.当我这样做onRefresh不会开火. 我已经在setState函数的回调中设置了GET请求,但这似乎没有做任何事情. 预期行为: 拉起视图调用onRefresh函数. 码: ... constructor(props) { super(props); this.state = { stories: [],isFetching: false,}; } componentDidMount() { this.fetchData() } onRefresh() { this.setState({ isFetching: true },function() { this.fetchData() }); } fetchData() { var that = this; axios.get('http://192.168.0.13:3000/api/story/get/by/geo') .then((res) => { that.setState({ stories: res.data,isFetching: false }); that.props.dispatch(StoryActions.setStories(res.data)) }) } render() { return ( <ScrollView> <FlatList onRefresh={() => this.onRefresh()} refreshing={this.state.isFetching} data={this.state.stories} keyExtractor={(item,index) => item.id} renderItem={({item}) => (<StoryFeed story={item} id={item.id} /> )} /> </ScrollView> ) } 版本信息 React-Native:0.45.0 节点:7.4.0 解决方法
React-Native问题.当嵌套在ScrollView中时,FlatList似乎没有检测到onRefresh:发行票证:
https://github.com/facebook/react-native/issues/14756
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |