caglardurmus / react-native-insta-story

Story component for React Native
MIT License
178 stars 85 forks source link

Doesn't work with dynamic data #22

Closed icodervj closed 1 year ago

icodervj commented 2 years ago

I tried changing data source to api data response but it doesn't work. Anyone else faced the same problem?

onneti2013 commented 2 years ago

I tried changing data source to api data response but it doesn't work. Anyone else faced the same problem?

I had the same problem and it can be solved with a setstate of already loaded data

const [storiesloaded, setStoriesloaded] = useState(0);

    { storiesloaded != 0 &&
        <InstaStory data={stories}
        duration={10}
        onStart={item => console.log(item)}
        onClose={item => console.log('close: ', item)}
        customSwipeUpComponent={<View>
                            <Text>Swipe</Text>
                        </View>}
        style={{marginTop: 30}}/>
    }

Just after your dynamic data is loaded you change storiesloaded to 1

altiparmakzeynep commented 2 years ago

@onneti2013 It's working! Thank you.