All files / Fetch index.js

100% Statements 6/6
100% Branches 2/2
100% Functions 2/2
100% Lines 6/6
1 2 3 4 5 6 7 8 9 10 11 12 13    1x 14x 14x       14x 14x 14x    
import { usePromise } from "../hooks"
 
export const useFetch = (url, using = fetch, delayMS) => {
    const [refresh, response, loading, err] = usePromise(using, [url], delayMS)
    return { refresh, response, loading, err }
}
 
export default props => {
    const { children = props.render, url, using, delayMS } = props
    const state = useFetch(url, using, delayMS)
    return children(state)
}