Skip to content

Instantly share code, notes, and snippets.

@gustfm
Created February 20, 2019 18:19
Show Gist options
  • Save gustfm/51ac8bde32d8d1f29cdd00386c8c0951 to your computer and use it in GitHub Desktop.
Save gustfm/51ac8bde32d8d1f29cdd00386c8c0951 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react'
import {
View,
FlatList,
ScrollView
} from 'react-native'
import {
Header
} from './style'
import Story from './components/Story'
export default class App extends Component {
state = {
stories: [
{key: 0, nickname: 'Seu story'},
{key: 1, nickname: 'imgus_', newStory: true},
{key: 2, nickname: 'imgus_', newStory: true},
{key: 3, nickname: 'imgus_', newStory: true},
{key: 4, nickname: 'imgus_'},
{key: 5, nickname: 'imgus_'},
{key: 6, nickname: 'imgus_'},
{key: 7, nickname: 'imgus_'},
{key: 8, nickname: 'imgus_'},
{key: 9, nickname: 'imgus_'}
]
}
render() {
const renderItem = ({item}) => {
return <Story nickname={item.nickname} newStory={item.newStory} />
}
return (
<View>
<Header />
<ScrollView>
<FlatList
showsHorizontalScrollIndicator={false}
horizontal={true}
data={this.state.stories}
extraData={this.state}
renderItem={renderItem}
keyExtractor={(_, index) => index.toString()} />
</ScrollView>
</View>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment