/** * title: 基础使用 * desc: 撤销跟重做操作。 */ import React, { useState } from 'react'; import useHistoryTravel from "../../useHistoryTravel"; export default () => { const { value, setValue, backLength, forwardLength, back, forward, go } = useHistoryTravel([ 'do homework', ]); const [inputValue, setInputValue] = useState(''); const [step, setStep] = useState(0); const onAdd = () => { setValue([...value, inputValue]); setInputValue(''); }; const onGo = () => { go(step); setStep(0); }; console.log(value); return (

TODO List

{value}
setInputValue(e.target.value)} placeholder="Please enter TODO name" style={{ width: 200, marginRight: 20 }} />
setStep(e.target.value as any)} max={forwardLength} min={backLength * -1} style={{ marginRight: 20, width: 60 }} />
); };