Skip to content

Instantly share code, notes, and snippets.

@hosseinmd
Last active November 5, 2020 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hosseinmd/ad985ef485f539e139191a95b7bb12d1 to your computer and use it in GitHub Desktop.
Save hosseinmd/ad985ef485f539e139191a95b7bb12d1 to your computer and use it in GitHub Desktop.
React-Concurrent example
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