Skip to content

Latest commit

 

History

History
40 lines (30 loc) · 1.09 KB

axios-hooks.md

File metadata and controls

40 lines (30 loc) · 1.09 KB

React Native Typescript Boilerplate

React Native Typescript Boilerplate

🍾 Axios Hooks Usage Example

Features

  • All the axios awesomeness you are familiar with
  • Zero configuration, but configurable if needed
import useAxios from 'axios-hooks';
import { View , Text, TouchableOpacity } from "react-native";

function App() {
  const [{ data, loading, error }, refetch] = useAxios(
    'https://reqres.in/api/users?delay=1'
  )

  if (loading) return <Text>Loading...</Text>
  if (error) return <Text>Error!</Text>

  return (
    <View>
      <TouchableOpacity onPress={refetch}>refetch</TouchableOpacity>
      <Text>{JSON.stringify(data, null, 2)}</Text>
    </View>
  )
}

Documentation

API