1.1.0 • Published 3 years ago
@y.dsh/hooks v1.1.0
import React, { useState } from 'react';
import usePreviousValues from '@dsh/hooks/lib/usePreviousValues'
function Example() {
const [count, setCount] = useState(0);
const prevCount = usePreviousValues(count);
return (
<div>
<div>{count} {prevCount}</div>
<button
onClick={() => setCount(count + 1)}
>++</button>
</div>
)
}