-
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.
Merge pull request #30 from Tamir198/dev
Dev
- Loading branch information
Showing
8 changed files
with
47 additions
and
29 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 |
---|---|---|
@@ -1,25 +1,19 @@ | ||
import { useState, useCallback } from "react"; | ||
import ReactPaginate from "https://cdn.skypack.dev/[email protected]"; | ||
import { AllCharacters } from "components"; | ||
import { config } from "constants/config"; | ||
import { useCurrPage } from "./useCurrPage"; | ||
|
||
import styles from "./CharacterGallery.module.css"; | ||
|
||
const CharacterGallery = () => { | ||
//TODO: use separated hook for this | ||
const { | ||
pageCount, | ||
startingPageNum, | ||
pageRangeDisplayed, | ||
marginPagesDisplayed, | ||
} = config; | ||
|
||
const [currPage, setCurrPage] = useState(startingPageNum); | ||
|
||
//todo change all handlers to use callback | ||
const handlePageClick = useCallback(({ selected }) => { | ||
setCurrPage(selected + 1); | ||
}, []); | ||
const { currPage, handlePageClick } = useCurrPage({ startingPageNum }); | ||
|
||
return ( | ||
<div> | ||
|
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,11 @@ | ||
import { useState, useCallback } from "react"; | ||
|
||
export const useCurrPage = ({ startingPageNum }) => { | ||
const [currPage, setCurrPage] = useState(startingPageNum); | ||
|
||
const handlePageClick = useCallback(({ selected }) => { | ||
setCurrPage(selected + 1); | ||
}, []); | ||
|
||
return { currPage, handlePageClick }; | ||
}; |
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,10 @@ | ||
import { useDispatch, useSelector } from "react-redux"; | ||
|
||
export const useCurrentCharacter = () => { | ||
const dispatch = useDispatch(); | ||
const { id: characterId, data } = useSelector( | ||
(state) => state.characters.currentCharacter | ||
); | ||
|
||
return { dispatch, id: characterId, data }; | ||
}; |
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
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,15 @@ | ||
import { useEffect } from "react"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import { fetchGeneralInfo } from "redux/actions"; | ||
|
||
export const useGeneralInfo = () => { | ||
const { generalInfo } = useSelector((state) => state.generalInfo); | ||
const dispatch = useDispatch(); | ||
|
||
useEffect(() => { | ||
dispatch(fetchGeneralInfo()); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
return generalInfo; | ||
}; |
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
c0d0f5c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
rickandmortybackend – ./
rickandmortybackend-git-master-tamir198.vercel.app
rickandmortybackend.vercel.app
rickandmortybackend-tamir198.vercel.app