message: refactor: useHistoryTravel
diff: -import { useState, useCallback, useRef } from 'react';
  +import { useRef, useState } from 'react';
  +import useMemoizedFn from '../useMemoizedFn';
  interface IData<T> {
  present?: T;
  @@ -25,7 +26,7 @@ const split = <T>(step: number, targetArr: T[]) => {
  return {
  _current: targetArr[index],
  _before: targetArr.slice(0, index),
  - _after: targetArr.slice(index + 1)
  + _after: targetArr.slice(index + 1),
  };
  };
  @@ -33,40 +34,33 @@ export default function useHistoryTravel<T>(initialValue?: T) {
  const [history, setHistory] = useState<IData<T | undefined>>({
  present: initialValue,
  past: [],
  - future: []
  + future: [],
  });
  const { present, past, future } = history;
  const initialValueRef = useRef(initialValue);
  - const reset = useCallback(
  - (...params: any[]) => {
  + const reset = (...params: any[]) => {
  const _initial = params.length > 0 ? params[0] : initialValueRef.current;
  initialValueRef.current = _initial;
  setHistory({
  present: _initial,
  future: [],
  - past: []
  + past: [],
  });
  - },
  - [history, setHistory]
  - );
  + };
  - const updateValue = useCallback(
  - (val: T) => {
  + const updateValue = (val: T) => {
  setHistory({
  present: val,
  future: [],
  - past: [...past, present]
  + past: [...past, present],
  });
  - },
  - [history, setHistory]
  - );
  + };
  - const _forward = useCallback(
  - (step: number = 1) => {
  + const _forward = (step: number = 1) => {
  if (future.length === 0) {
  return;
  }
  @@ -74,14 +68,11 @@ export default function useHistoryTravel<T>(initialValue?: T) {
  setHistory({
  past: [...past, present, ..._before],
  present: _current,
  - future: _after
  + future: _after,
  });
  - },
  - [history, setHistory]
  - );
  + };
  - const _backward = useCallback(
  - (step: number = -1) => {
  + const _backward = (step: number = -1) => {
  if (past.length === 0) {
  return;
  }
  @@ -90,14 +81,11 @@ export default function useHistoryTravel<T>(initialValue?: T) {
  setHistory({
  past: _before,
  present: _current,
  - future: [..._after, present, ...future]
  + future: [..._after, present, ...future],
  });
  - },
  - [history, setHistory]
  - );
  + };
  - const go = useCallback(
  - (step: number) => {
  + const go = (step: number) => {
  const stepNum = typeof step === 'number' ? step : Number(step);
  if (stepNum === 0) {
  return;
  @@ -106,22 +94,20 @@ export default function useHistoryTravel<T>(initialValue?: T) {
  return _forward(stepNum);
  }
  _backward(stepNum);
  - },
  - [_backward, _forward]
  - );
  + };
  return {
  value: present,
  - setValue: updateValue,
  backLength: past.length,
  forwardLength: future.length,
  - go,
  - back: useCallback(() => {
  + setValue: useMemoizedFn(updateValue),
  + go: useMemoizedFn(go),
  + back: useMemoizedFn(() => {
  go(-1);
  - }, [go]),
  - forward: useCallback(() => {
  + }),
  + forward: useMemoizedFn(() => {
  go(1);
  - }, [go]),
  - reset
  + }),
  + reset: useMemoizedFn(reset),
  };
  }
  