2c4f4092d8
* always show advanced * fix test * always show the price, less jitter * show tokens in price field * fix the dropdown sticking around when switching between swap/send * lint * fix ios scrolling the modal body into the viewport bug * don't use react-spring for simple slide animation * safer price impact constants
14 lines
364 B
TypeScript
14 lines
364 B
TypeScript
import { useEffect, useState } from 'react'
|
|
|
|
/**
|
|
* Returns the last truthy value of type T
|
|
* @param value changing value
|
|
*/
|
|
export default function useLast<T>(value: T | undefined | null): T | null | undefined {
|
|
const [last, setLast] = useState<T | null | undefined>(value)
|
|
useEffect(() => {
|
|
setLast(last => value ?? last)
|
|
}, [value])
|
|
return last
|
|
}
|