-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(products): adjusted create products
- Loading branch information
1 parent
69cdeb3
commit 30eed81
Showing
2 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
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,29 @@ | ||
import React, { useContext, useState } from 'react'; | ||
|
||
import Loading from '../Loading/Loading' | ||
import { GlobalState } from '../../GlobalState'; | ||
import './Products.css'; | ||
|
||
// Load additional Products for pagination | ||
const LoadMore = () => { | ||
|
||
const state = useContext(GlobalState) | ||
const [page, setPage] = state.productsAPI.page | ||
const [result] = state.productsAPI.result | ||
const [loading] = useState(false) | ||
|
||
if (loading) return <div className="products"><Loading /></div> | ||
|
||
return ( | ||
<> | ||
<div className="load_more"> | ||
{ | ||
result < page * 9 ? "" | ||
: <button onClick={() => setPage(page + 1)}>Load More</button> | ||
} | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
export default LoadMore; |