diff --git a/examples/react/README.md b/examples/react/README.md new file mode 100644 index 0000000..8cef818 --- /dev/null +++ b/examples/react/README.md @@ -0,0 +1,7 @@ +# React example. + +There used to be a simple react example with contexts, but as I mainly work with React on +the frontend, I decided to create another library to solve this usage in a beautiful, +faster and minimalistic way. + +See [**Axios Cache Hooks**](https://tinylibs.js.org/packages/axios-cache-hooks/) diff --git a/examples/react/app.js b/examples/react/app.js deleted file mode 100644 index 700ea0c..0000000 --- a/examples/react/app.js +++ /dev/null @@ -1,38 +0,0 @@ -/* eslint-disable */ - -import { useState } from 'react'; -import { useAxios } from './axios-context'; - -export const App = () => { - // You can use react context, as exemplified here - // but you can also just export the AxiosCacheInstance - // from a file and use it directly. Happy coding :) - const axios = useAxios(); - - const [{ data, error, loading }, setResponse] = useState({ - data: [], - loading: true, - error: null - }); - - useEffect(() => { - axios.get('https://jsonplaceholder.typicode.com/users').then( - ({ data }) => setResponse({ data, loading: false, error: null }), - (error) => setResponse({ data: [], loading: false, error }) - ); - }, []); - - if (loading) { - return