Added react-lazy-load-image-component for lazy loading image in PokemonCard
parent
3926267d77
commit
2857b1d131
|
@ -9,6 +9,7 @@
|
||||||
"@reduxjs/toolkit": "^1.9.3",
|
"@reduxjs/toolkit": "^1.9.3",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
|
"react-lazy-load-image-component": "^1.5.6",
|
||||||
"react-redux": "^8.0.5",
|
"react-redux": "^8.0.5",
|
||||||
"react-scripts": "5.0.1",
|
"react-scripts": "5.0.1",
|
||||||
"typescript": "^4.9.5",
|
"typescript": "^4.9.5",
|
||||||
|
@ -76,6 +77,7 @@
|
||||||
"@types/node": "^16.18.14",
|
"@types/node": "^16.18.14",
|
||||||
"@types/react": "^18.0.28",
|
"@types/react": "^18.0.28",
|
||||||
"@types/react-dom": "^18.0.11",
|
"@types/react-dom": "^18.0.11",
|
||||||
|
"@types/react-lazy-load-image-component": "^1.5.2",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.56.0",
|
"@typescript-eslint/eslint-plugin": "^5.56.0",
|
||||||
"@typescript-eslint/parser": "^5.56.0",
|
"@typescript-eslint/parser": "^5.56.0",
|
||||||
"babel-plugin-named-exports-order": "^0.0.2",
|
"babel-plugin-named-exports-order": "^0.0.2",
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { LazyLoadImage } from 'react-lazy-load-image-component';
|
||||||
|
import 'react-lazy-load-image-component/src/effects/blur.css';
|
||||||
import { Tooltip, Zoom } from '@mui/material';
|
import { Tooltip, Zoom } from '@mui/material';
|
||||||
|
|
||||||
import './PokemonCard.css';
|
import './PokemonCard.css';
|
||||||
|
@ -97,7 +99,15 @@ export default function PokemonCard({
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="image__container">
|
<div className="image__container">
|
||||||
<img src={image} alt={name} />
|
<LazyLoadImage
|
||||||
|
alt={name}
|
||||||
|
height={150}
|
||||||
|
src={image}
|
||||||
|
visibleByDefault={false}
|
||||||
|
delayMethod={'debounce'}
|
||||||
|
effect="blur"
|
||||||
|
className="img_thumbnail"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="poke__name">
|
<div className="poke__name">
|
||||||
<h3>{name}</h3>
|
<h3>{name}</h3>
|
||||||
|
|
|
@ -91,7 +91,9 @@ export const pokedexSlice: Slice<PokedexState> = createSlice({
|
||||||
state.pokemonCardList = action.payload.map(pokemon => ({
|
state.pokemonCardList = action.payload.map(pokemon => ({
|
||||||
id: pokemon.id,
|
id: pokemon.id,
|
||||||
name: pokemon.name,
|
name: pokemon.name,
|
||||||
image: pokemon.sprites.other.dream_world.front_default,
|
image: pokemon.sprites.other.dream_world.front_default
|
||||||
|
? pokemon.sprites.other.dream_world.front_default
|
||||||
|
: pokemon.sprites.other['official-artwork'].front_default,
|
||||||
types: pokemon.types.map(type => type.type.name),
|
types: pokemon.types.map(type => type.type.name),
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
|
@ -76,6 +76,9 @@ export interface PokemonResponseData {
|
||||||
dream_world: {
|
dream_world: {
|
||||||
front_default: string;
|
front_default: string;
|
||||||
};
|
};
|
||||||
|
'official-artwork': {
|
||||||
|
front_default: string;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
21
yarn.lock
21
yarn.lock
|
@ -3649,6 +3649,14 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
"@types/react" "*"
|
"@types/react" "*"
|
||||||
|
|
||||||
|
"@types/react-lazy-load-image-component@^1.5.2":
|
||||||
|
version "1.5.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/react-lazy-load-image-component/-/react-lazy-load-image-component-1.5.2.tgz#b87e814b6b91853b802f04465364ff1e913dce6a"
|
||||||
|
integrity sha512-4NLJsMJVrMv18FuMIkUUBVj/PH9A+BvLKrZC75EWiEFn1IsMrZHgL1tVKw5QBfoa0Qjz6SkWIzEvwcyZ8PgnIg==
|
||||||
|
dependencies:
|
||||||
|
"@types/react" "*"
|
||||||
|
csstype "^3.0.2"
|
||||||
|
|
||||||
"@types/react-transition-group@^4.4.5":
|
"@types/react-transition-group@^4.4.5":
|
||||||
version "4.4.5"
|
version "4.4.5"
|
||||||
resolved "https://registry.yarnpkg.com/@types/react-transition-group/-/react-transition-group-4.4.5.tgz#aae20dcf773c5aa275d5b9f7cdbca638abc5e416"
|
resolved "https://registry.yarnpkg.com/@types/react-transition-group/-/react-transition-group-4.4.5.tgz#aae20dcf773c5aa275d5b9f7cdbca638abc5e416"
|
||||||
|
@ -10230,6 +10238,11 @@ lodash.sortby@^4.7.0:
|
||||||
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
|
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
|
||||||
integrity sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==
|
integrity sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==
|
||||||
|
|
||||||
|
lodash.throttle@^4.1.1:
|
||||||
|
version "4.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4"
|
||||||
|
integrity sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==
|
||||||
|
|
||||||
lodash.uniq@4.5.0, lodash.uniq@^4.5.0:
|
lodash.uniq@4.5.0, lodash.uniq@^4.5.0:
|
||||||
version "4.5.0"
|
version "4.5.0"
|
||||||
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
|
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
|
||||||
|
@ -12636,6 +12649,14 @@ react-is@^18.0.0, react-is@^18.2.0:
|
||||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b"
|
resolved "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b"
|
||||||
integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==
|
integrity sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==
|
||||||
|
|
||||||
|
react-lazy-load-image-component@^1.5.6:
|
||||||
|
version "1.5.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/react-lazy-load-image-component/-/react-lazy-load-image-component-1.5.6.tgz#a4b84257be21b1825680b4e158d167c08aeda5ff"
|
||||||
|
integrity sha512-M0jeJtOlTHgThOfgYM9krSqYbR6ShxROy/KVankwbw9/amPKG1t5GSGN1sei6Cyu8+QJVuyAUvQ+LFtCVTTlKw==
|
||||||
|
dependencies:
|
||||||
|
lodash.debounce "^4.0.8"
|
||||||
|
lodash.throttle "^4.1.1"
|
||||||
|
|
||||||
react-merge-refs@^1.0.0:
|
react-merge-refs@^1.0.0:
|
||||||
version "1.1.0"
|
version "1.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/react-merge-refs/-/react-merge-refs-1.1.0.tgz#73d88b892c6c68cbb7a66e0800faa374f4c38b06"
|
resolved "https://registry.yarnpkg.com/react-merge-refs/-/react-merge-refs-1.1.0.tgz#73d88b892c6c68cbb7a66e0800faa374f4c38b06"
|
||||||
|
|
Loading…
Reference in New Issue