-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task/wg-199-react-query-initial-setup
- Loading branch information
1 parent
e2b7ce6
commit 4d241fd
Showing
9 changed files
with
228 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as useProjects } from './projects/useProjects'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { UseQueryResult } from 'react-query'; | ||
import { Project } from '../../types'; | ||
import { useGet } from '../../requests'; | ||
|
||
const useProjects = (): UseQueryResult<Project[]> => { | ||
const query = useGet<Project[]>({ | ||
endpoint: '/projects/', | ||
key: ['project'], | ||
baseUrl: 'https://agave.designsafe-ci.org/geo/v2', | ||
}); | ||
return query; | ||
}; | ||
|
||
export default useProjects; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
import { QueryClient, QueryClientProvider } from 'react-query'; | ||
import App from './AppRouter'; | ||
import './index.css'; | ||
import store from './redux/store'; | ||
import { Provider } from 'react-redux'; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( | ||
<React.StrictMode> | ||
<Provider store={store}> | ||
<App /> | ||
<QueryClientProvider client={queryClient}> | ||
<App /> | ||
</QueryClientProvider> | ||
</Provider> | ||
</React.StrictMode> | ||
); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
import React from 'react'; | ||
import { | ||
useGetGeoapiProjectsQuery, | ||
useGetGeoapiUserInfoQuery, | ||
} from '../../redux/api/geoapi'; | ||
import { useProjects } from '../../hooks'; | ||
|
||
function MainMenu() { | ||
useGetGeoapiProjectsQuery(); | ||
useGetGeoapiUserInfoQuery(); | ||
return <h2>Main Menu</h2>; | ||
const { data, isLoading, error } = useProjects(); | ||
Check warning on line 5 in react/src/pages/MainMenu/MainMenu.tsx GitHub Actions / React-Linting
|
||
return ( | ||
<> | ||
<h2>Main Menu</h2> | ||
<h5>You have {data?.length} projects. </h5> | ||
</> | ||
); | ||
} | ||
|
||
export default MainMenu; |
Oops, something went wrong.