6

I wish to use this package in React Native, a carousel implemented with Flatlist, and enables horizontal swipe to swipe through images.

https://github.com/gusgard/react-native-swiper-flatlist

What happen is I would like to use this in a ScrollView since my screen is pretty long and requires vertical scrolling.

However if I use this package in ScrollView, images and the component doesn't load. If i use View instead of ScrollView, everything works just fine, and images load.

May I know what are the things to note in implementing Flatlist in a ScrollView component?

I tried to create snack but it doesn't seems to load remote images

https://snack.expo.io/@daveteu/scrollflatlist-test

2
  • i added an example on snack but doesn't seems to be able to load remote images on snack. Commented Aug 27, 2018 at 10:45
  • Try to modify your structure. See my answer below. Let me know if it works, or if that is not what you wanted. Commented Aug 27, 2018 at 10:49

2 Answers 2

2

You will need to restructure your component to look like this:

<View>
  <ScrollView removeClippedSubviews={false}>
    <View>
      <SwiperFlatList>
      </SwiperFlatList>
    </View>
    //Your other stuff go here that need scrollview
  </ScrollView>
</View>

Full code example:

  render() {
    return (
      <View>
        <ScrollView removeClippedSubviews={false}>
          <View style={styles.container}>
            <SwiperFlatList
              autoplay
              autoplayDelay={2}
              autoplayLoop
              index={2}
              showPagination
            >
              <View style={[styles.child, { backgroundColor: 'tomato' }]}>
                <Text style={styles.text}>1</Text>
              </View>
              <View style={[styles.child, { backgroundColor: 'thistle' }]}>
                <Text style={styles.text}>2</Text>
              </View>
              <View style={[styles.child, { backgroundColor: 'skyblue' }]}>
                <Text style={styles.text}>3</Text>
              </View>
              <View style={[styles.child, { backgroundColor: 'teal' }]}>
                <Text style={styles.text}>4</Text>
              </View>
            </SwiperFlatList>
          </View>
          ...// Your components that require scrolling go here
        </ScrollView>
      </View>
    );
Sign up to request clarification or add additional context in comments.

3 Comments

It seems to work so far! thank u, i will do more modification and testing and update this thread.
You should use the property “renderAll”
it is not helping me
-1

<Flatlist nestedScrollEnabled ... />

Here you go.

Comments

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.