// @flow import React, { useState, useCallback } from 'react'; import * as ICONS from 'constants/icons'; import Button from 'component/button'; type Props = { isBackward: boolean, history: { entries: { key: string, title: string }[], go: number => void, goBack: () => void, goForward: () => void, index: number, length: number, location: { pathname: string }, push: string => void, }, }; const ButtonNavigation = (props: Props) => { const { isBackward, history } = props; const [showHistory, setShowHistory] = useState(false); const makeEntrySlice = useCallback(() => { const left = isBackward ? 1 : history.index + 1; const right = isBackward ? history.index : history.length; return history.entries.slice(left, right); }, [history, isBackward]); const makeItem = useCallback( (entry, index) => { const goArg = isBackward ? index - history.index : history.index - index; console.log(`index: ${index}, currentIndex: ${history.index}, goArg: ${goArg}, title: ${entry.title}`); return (