This file contains hidden or 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, useCallback } from 'react' | |
| const useFetch = (fetcher, { params = {}, immediate = false } = {}) => { | |
| const [loading, setLoading] = useState(false) | |
| const [data, setValue] = useState(null) | |
| const [error, setError] = useState(null) | |
| const execute = useCallback( | |
| (executeParams) => { | |
| setLoading(true) |
This file contains hidden or 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 useQuery = () => { | |
| const url = new URL(window.location.href) | |
| const params = new URLSearchParams(url.search) | |
| const query = {} | |
| for(const pair of params.entries()) { | |
| query[pair[0]] = pair[1] | |
| } | |
| return query |