Skip to content

Commit

Permalink
fix(rn): device info pull to refresh
Browse files Browse the repository at this point in the history
Signed-off-by: Godefroy Ponsinet <godefroy.ponsinet@outlook.com>
  • Loading branch information
90dy committed Oct 29, 2018
1 parent 56cb86b commit 1b8ca8d
Showing 1 changed file with 28 additions and 6 deletions.
@@ -1,9 +1,16 @@
import {
Clipboard,
RefreshControl,
ScrollView,
Text,
TouchableOpacity,
} from 'react-native'
import React, { PureComponent } from 'react'
import { Text, ScrollView, TouchableOpacity, Clipboard } from 'react-native'

import { GetDeviceInfos } from '../../../../graphql/queries'
import { Header } from '../../../Library'
import { colors } from '../../../../constants'
import { padding } from '../../../../styles'
import { GetDeviceInfos } from '../../../../graphql/queries'

export default class DeviceInfos extends PureComponent {
static navigationOptions = ({ navigation }) => ({
Expand All @@ -19,12 +26,19 @@ export default class DeviceInfos extends PureComponent {

state = {
infos: {},
refreshing: false,
}

fetch = () => {
this.setState({ refreshing: true }, () =>
GetDeviceInfos.then(data => {
this.setState({ infos: data.DeviceInfos.infos, refreshing: false })
})
)
}

componentDidMount () {
GetDeviceInfos.then(data => {
this.setState({ infos: data.DeviceInfos.infos })
})
this.fetch()
}

render () {
Expand Down Expand Up @@ -60,7 +74,15 @@ export default class DeviceInfos extends PureComponent {
}

return (
<ScrollView style={{ backgroundColor: colors.background }}>
<ScrollView
style={{ backgroundColor: colors.background }}
refreshControl={
<RefreshControl
refreshing={this.state.refreshing}
onRefresh={this.fetch}
/>
}
>
{fields}
</ScrollView>
)
Expand Down

0 comments on commit 1b8ca8d

Please sign in to comment.