mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-12 22:29:41 +08:00
Allows RefreshControl to be mounted with refreshing = true
Summary: RefreshControl did not start refreshing when refreshing was set to true initially. It also did not start refreshing on iOS when setting the prop from false to true without doing a pull to refresh gesture. This was a pain in the ass to make work on iOS because UIRefreshControl seems super sensitive to when beginRefreshing can be called, for the initial render I need to call it in layoutSubviews. I also have to manually adjust the scrollview content offset when calling beginRefreshing. The code is a bit hacky but it was the only solution I found that was actually working. Fixes #5716 Closes https://github.com/facebook/react-native/pull/5745 Reviewed By: svcscm Differential Revision: D2910716 Pulled By: nicklockwood fb-gh-sync-id: d60e73bcfe8d86bb01249ba5f17e6a23c5a5aff6
This commit is contained in:
committed by
facebook-github-bot-5
parent
7b22606f49
commit
3e1f1ea7bb
@@ -71,8 +71,15 @@ public class SwipeRefreshLayoutManager extends ViewGroupManager<ReactSwipeRefres
|
||||
}
|
||||
|
||||
@ReactProp(name = "refreshing")
|
||||
public void setRefreshing(ReactSwipeRefreshLayout view, boolean refreshing) {
|
||||
view.setRefreshing(refreshing);
|
||||
public void setRefreshing(final ReactSwipeRefreshLayout view, final boolean refreshing) {
|
||||
// Use `post` otherwise the control won't start refreshing if refreshing is true when
|
||||
// the component gets mounted.
|
||||
view.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
view.setRefreshing(refreshing);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user