-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6d9877e
commit 0f6c8f6
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {createContext} from "@types/react"; | ||
|
||
const ChemContext = createContext({}) | ||
export default ChemContext | ||
|
||
export const ChemProvider = ({children}) => { | ||
|
||
let getContainerList | ||
let getContainer | ||
|
||
let contextData = { | ||
// ContainerList:ContainerList, | ||
// Container:Container, | ||
// show:show // in context or on table page? | ||
} | ||
return( | ||
<ChemContext.Provider value={contextData}> | ||
{/*{loading ? null : children}*/} | ||
</ChemContext.Provider> | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useState, useEffect } from 'react'; | ||
import axios from 'axios'; | ||
|
||
axios.defaults.baseURL = 'https://jsonplaceholder.typicode.com'; | ||
|
||
const useAxios2 = (params, authentication=false) => { | ||
const [response, setResponse] = useState(undefined); | ||
const [error, setError] = useState(''); | ||
const [loading, setLoading] = useState(true); | ||
|
||
const fetchData = async params => { | ||
try { | ||
const result = await axios.request(params); | ||
setResponse(result.data); | ||
} catch( error ) { | ||
setError(error); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
fetchData(params); | ||
}, []); // execute once only | ||
|
||
return { response, error, loading }; | ||
}; | ||
|
||
export default useAxios2 |