picpagination.tsx 1.94 KB
Newer Older
백승민's avatar
백승민 committed
1
// import React, { useRef, useState} from "react";
백승민's avatar
백승민 committed
2

백승민's avatar
백승민 committed
3
4
5
6
// type num = {
//     total: number,
//     page: number,
//     setPage: Function
백승민's avatar
1    
백승민 committed
7

백승민's avatar
백승민 committed
8
// }
백승민's avatar
1    
백승민 committed
9

백승민's avatar
백승민 committed
10
11
12
13
14
15
16
17
18
19
20
21
22
// export function Pagination({ total, page, setPage}: num) {
//     const numPages = Math.ceil(total / 15);
//     const firstLeftClick = useRef(true);
//     const firstRightClick = useRef(true);
    
//     const leftClick = () => {
//         if (firstLeftClick.current) {
//             firstLeftClick.current = false;
//             firstRightClick.current = true;
//         } else {
//             setPage(page - 1)
//         }
//     };
백승민's avatar
백승민 committed
23

백승민's avatar
백승민 committed
24
25
26
27
28
29
30
31
32
//     const rightClick = () => {
//         if (firstRightClick.current) {
//             firstLeftClick.current = true;
//             firstRightClick.current = false;
//         } else {
//             setPage(page + 1)
//         }
//   };
//     };
백승민's avatar
백승민 committed
33

백승민's avatar
백승민 committed
34
35
36
37
38
39
40
41
//     return (
//         <div>
//             <button onClick={leftClick} disabled={page === 1}>
//                 &lt;{page}
//             </button>
//             <button onClick={rightClick} disabled={page === numPages}>
//                 &gt;
//             </button>
백승민's avatar
백승민 committed
42

백승민's avatar
백승민 committed
43
44
45
//         </div>
//     );
// };
백승민's avatar
백승민 committed
46

백승민's avatar
1    
백승민 committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

// export function PaginationRight({ total, page, setPage }: num) {
//     const numPages = Math.ceil(total / 15);
//     const firstLeftClick = useRef(true);
//     const firstRightClick = useRef(true);


//     const right = () => {
//         if (firstRightClick.current) {
//             firstLeftClick.current = true;
//             firstRightClick.current = false;
//         } else {
//             setPage(page + 1)
//         }
//     };

//     return (
//         <div>
//             <button onClick={right} disabled={page === numPages}>
//                 &gt;
//             </button>
//         </div>
//     );
// };
백승민's avatar
백승민 committed
71
72
73
74
75
76
77
78

    {/* {Array(numPages)
        .fill(1)
        .map((_, i) => (
            <button key={i + 1} onClick={() => setPage(i + 1)}>
                {i + 1}
            </button>
        ))} */}