This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const fetchData = (params:Record<string,string>) => { | |
const [loading,setLoading] = useState(true) | |
const [data,setData] = useState([]) | |
const [errorMsg,setErr] = useState("") | |
useEffect(()=>{ | |
// axios call | |
axios.get(`/someUrl`) | |
.then(res=>{ | |
setData(res.data) | |
setLoading(false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {useState} from 'react'; | |
import AxiosConfig from '../services/axiosConfig'; //use own axios component | |
export type SubmitFunctionReturn = { | |
isSuccess: boolean; | |
data?: any | null; | |
error?: string | null; | |
}; | |
export const submitFormHook = () => { | |
const [loading, setLoading] = useState(false); | |
const api = new AxiosConfig(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {useEffect, useState} from 'react'; | |
import AxiosConfig from '../services/axiosConfig'; // use your axios config | |
export function getDataOnMount<T>(endpoint: string, dependency: any[]) { | |
const [loading, setLoading] = useState(true); | |
const api = new AxiosConfig(); | |
const [data, setData] = useState<T>(); | |
const [errorMsg,setErr] = useState("") | |
useEffect(() => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Section: React.FC< | |
PropsWithChildren<{ | |
title: string; | |
}> | |
> = ({ children, title }) => { | |
const isDarkMode = useColorScheme() === "dark"; | |
return ( | |
<View style={styles.sectionContainer}> | |
<Text | |
style={[ |