Skip to content

Commit

Permalink
some upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
ake123 committed Jan 16, 2024
1 parent e872bd7 commit 3e60236
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"web-vitals": "^2.1.4"
},
"scripts": {
"predeploy":"npm run build",
"deploy":"gh-pages-d build",
"predeploy": "npm run build",
"deploy": "gh-pages-d build",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
Expand Down
4 changes: 4 additions & 0 deletions src/component/Product.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ const Product = () => {
const [loading, setLoading] = useState(false);

useEffect(() => {
let componentMounted = true;
const getProduct = async () => {
setLoading(true);
const response = await fetch(`https://fakestoreapi.com/products/${id}`);
setProduct(await response.json());
setLoading(false);
};
getProduct();
return () => {
componentMounted = false;
};
}, []);

const Loading = () => {
Expand Down

0 comments on commit 3e60236

Please sign in to comment.