8

Edit: There seems to be a bug in React Native. I have created a bug on GitHub. For everyone coming for a solution: There seems to be none at the moment.

https://github.com/facebook/react-native/issues/23988

––––

I'm using a translucent header, which is why I gave the ScrollView a paddingTop to offset the content. When I pull down to refresh, the spinner is still at the top.

I have tried to use contentInset={{ top: 80 }} to offset everything, but there is an issue on iOS where it sometimes is not picked up correctly and set to 0.

Are there any other ways to get the RefreshControl to start lower?

enter image description here

This is my component:

  <Animated.ScrollView
    scrollEventThrottle={1}
    onScroll={Animated.event(
      [{ nativeEvent: { contentOffset: { y: this.state.scrollY } } }],
      { useNativeDriver: true },
    )}
    contentInset={{ top: headerHeight() + 10 }}
  >
2
  • Did you resolve this problem? Commented Mar 3, 2020 at 9:50
  • @AlexChin No, there is no solution currently. There is an open issue on github: github.com/facebook/react-native/issues/23988 Commented Mar 4, 2020 at 10:02

3 Answers 3

3

I resolved like this.

contentInset={{ top: headerHeight }}
contentOffset={{y: -headerHeight}}

I use these props to FlatList.

Sign up to request clarification or add additional context in comments.

1 Comment

This worked for iOS. Had to use profressViewOffset on RefreshControl for android. stackoverflow.com/a/66691559/9153273
3
<RefreshControl
  progressViewOffset={40}
  refreshing={loading}
  onRefresh={onRefresh}
/>

progressViewOffset is how you do it, that would offset the loader 40 pixels lower.

2 Comments

progressViewOffset is Android only
progressViewOffset now supports both android & iOS as of version 0.65 reactnative.dev/docs/0.64/refreshcontrol
2

Did you set padding for the style or for the contentContainerStyle?

Can you provide some code snippet what properties does your ScrollView have and by what is wrapped?

1 Comment

I have added the code for my ScrollView above. If I set contentContainerStyle with padding, there's space I don't want between my child components and the refresh control. As mentioned, contentInset works soooometimes. But sometimes not. It's really weird

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.