react-native-custom-hooks
v1.1.2
Published
# `<customhooks />` [![npm](https://img.shields.io/npm/v/react-customs-hooks.svg)](https://www.npmjs.com/package/react-customs-hooks) [![npm](https://img.shields.io/npm/dm/react-customs-hooks.svg)](https://www.npmjs.com/package/react-customs-hooks)
Downloads
16
Readme
customhooks
<customhooks />
| | | | | --------------------- | --------------------- | ------------------ |
Install
npm i react-customs-hooks
yarn add react-customs-hooks
import { useDelete, useFetch, usePost, useUpdate, useGetSecureStore , usePostSecureStore, usePostAsyncStore, useGetAsyncStore } from 'react-customs-hooks'
Usage -useDetete Hook
const App = () => {
const {data, status, error, loading} = useFetch('https://jsonplaceholder.typicode.com/users')
return (
<View>
{ data && data.map(item=> <Text>{item.name}</Text>)}
</View>
)
}
Usage -usePost Hook
const {PostDataFnc, data, error, status, loading} = usePost('url', body,config )
console.log(data)
return (
<View>
<Button onPress={()=>PostDataFnc() } title="Press" />
</View>
)
}
Usage - usePost Hook
const { deleteDataFnc, data, error, status, loading } = usePost('url', body,config )
console.log(data)
return (
<View>
<Button onPress={()=>deleteDataFnc() } title="Press" />
</View>
)
}
Usage - useUpdate Hook
const { updataDataFnc, data, error, status, loading } = useUpdate('url', body,config )
console.log(data)
return (
<View>
<Button onPress={()=>updataDataFnc() } title="Press" />
</View>
)
Usage - useGetSecureStore Hook
const { data , getData, loading, error } = useGetSecureStore(key, initialValue)
console.log(data)
return (
<View>
<Text>{data.name}</Text>
<Text>{data.email}</Text>
</View>
)
}
Usage - useGetSecureStore Hook
const { data , getData, loading, error } = useGetSecureStore()// if you are not using here key or initialValue you can use it when hook will be call
console.log(data)
return (
<View>
<Button onPress={()=>getData(key, initialValue)} titile="Call Hook" />
<Text>{data.name}</Text>
<Text>{data.email}</Text>
</View>
)
}
Usage - usePostSecureStore Hook
const {storeData, error, loading} = usePostSecureStore(key, initialValue)
console.log(data)
return (
<View>
<Button onPress={()=>storeData()} />
</View>
)
}
Usage - other way of usePostSecureStore Hook
const {storeData, error, loading} = usePostSecureStore()
console.log(data)
return (
<View>
<Button onPress={()=>storeData(key, initialValue)} />
</View>
)
License
MIT.