Last active
November 5, 2020 19:32
-
-
Save hosseinmd/ad985ef485f539e139191a95b7bb12d1 to your computer and use it in GitHub Desktop.
React-Concurrent example
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 { useFetching } from "react-concurrent"; | |
const app = () => { | |
const [query, setQuery] = useState('a query for search'); | |
const { data, isLoading, error } = useFetching(() => { | |
const result = await axios( | |
`http://hn.algolia.com/api/v1/search?query=${query}`, | |
); | |
return result.data | |
}, | |
[query] | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment