Move Loading screen into Pokedex.tsx

develop
Jason Zhu 2023-03-26 15:56:51 +11:00
parent 33b1f4f79c
commit db682dc2a2
2 changed files with 14 additions and 16 deletions

View File

@ -2,18 +2,8 @@ import React from 'react';
import './App.css'; import './App.css';
import Header from 'components/Header'; import Header from 'components/Header';
import Pokedex from './features/Pokedex'; import Pokedex from './features/Pokedex';
import { useGetPokemonListQuery } from './features/Pokedex/pokedexApi';
import Loading from './components/Loading';
function App() { function App() {
const { data, error, isLoading } = useGetPokemonListQuery(100);
if (isLoading) {
return (
<div className="App app_container">
<Loading />
</div>
);
}
return ( return (
<div className="App app_container"> <div className="App app_container">
<Header /> <Header />

View File

@ -1,19 +1,27 @@
import React from 'react'; import React from 'react';
import Pokemon from './Pokemon'; import Pokemon from './Pokemon';
import Filters from './Filters'; import Filters from './Filters';
import { useGetPokemonListQuery } from './pokedexApi';
import Loading from 'components/Loading';
import charizard from 'features/Pokedex/Pokemon/assets/stories/charizard.svg'; import charizard from 'features/Pokedex/Pokemon/assets/stories/charizard.svg';
const Pokedex = () => { const Pokedex = () => {
const { data, error, isLoading } = useGetPokemonListQuery(100);
return ( return (
<> <>
<Filters /> <Filters />
{isLoading ? (
<Loading />
) : (
<Pokemon <Pokemon
name={'Charizard'} name={'Charizard'}
number={6} number={6}
image={charizard} image={charizard}
types={['fire', 'flying']} types={['fire', 'flying']}
/> />
)}
</> </>
); );
}; };