mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-15 12:42:45 +00:00
refactor useEffect for updating currentPage state
The current page and the current page input share the same value, so the useEffect hook can be simplified.
This commit is contained in:
@@ -16,12 +16,8 @@ const ToolBar = ({ onZoomChange, currentPage, onPageChange, totalPages })=>{
|
|||||||
}, [zoomLevel]);
|
}, [zoomLevel]);
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
setState((prevState)=>({
|
setPageInput(currentPage);
|
||||||
...prevState,
|
}, [currentPage])
|
||||||
currentPage : currentPage,
|
|
||||||
pageNumberInput : currentPage,
|
|
||||||
}));
|
|
||||||
}, [currentPage]);
|
|
||||||
|
|
||||||
const handleZoomChange = (delta)=>{
|
const handleZoomChange = (delta)=>{
|
||||||
const zoomChange = _.clamp(zoomLevel + delta, minZoom, maxZoom);
|
const zoomChange = _.clamp(zoomLevel + delta, minZoom, maxZoom);
|
||||||
|
|||||||
Reference in New Issue
Block a user