react-use
react-use copied to clipboard
useMediatedState should allow type conversion
What is the current behavior?
current typing for useMediatedState
expects the mediated state to be the same as the initial/incoming value
What is the expected behavior?
it should allow to map onto another type i.e.: const [count, setCount] = useMediatedState(parseInt, 0)
or explicitly:
const [count, setCount] = useMediatedState<number, string>(parseInt, 0)
(order could be also switched depending on the pov)
A little about versions:
- OS: windows
- Browser (vendor and version): chrome
- React: v18
-
react-use
: 17.4.0 - Did this worked in the previous package version? doubt it