Skip to content

Instantly share code, notes, and snippets.

@CharlesMangwa
Last active March 15, 2018 19:41
Show Gist options
  • Save CharlesMangwa/4f39461c9c4152c546ee14fd894c8180 to your computer and use it in GitHub Desktop.
Save CharlesMangwa/4f39461c9c4152c546ee14fd894c8180 to your computer and use it in GitHub Desktop.
React Data Fetching - Use case with/without`<ConnectedFetch>`
import React, { Component } from 'react'
import { View, Text } from 'react-native'
import { Fetch } from 'react-data-fetching'
export default class Container extends Component {
render() {
return (
<>
// Without <ConnectedFetch>
<Fetch
url="https://api.nyan.com/cats/meowssages"
headers={{
'X-Nyan-Token': 'superNyan',
}}
>
{({ data }) => (
<View>
<Text>You have {data.total} unread messages.</Text>
</View>
)}
</Fetch>
// With <ConnectedFetch>
<Fetch path="/cats/meowssages">
{({ data, store }) => (
<View>
<Text>Hello {store.user.firstName}!</Text>
<Text>You have {data.total} unread messages.</Text>
</View>
)}
</Fetch>
</>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment