Re:Show HN: Redux with a UseState Hook
by cakerace on Friday May 29, 2020 @02:56AM
(#23346993)
Won't using string paths like lodash makes it hard to use this library with typescript?
[ Parent
| on HN ]
Re:Show HN: Redux with a UseState Hook
by harrisonhope on Friday May 29, 2020 @03:04AM
(#23347043)
Probably a fair point. I hadn't really taken typescript into account for the purposes of this library.
Since in TS you can guarantee the user has optional chaining, so it may not be that big a change
// instead of
useHookedOnState('app.components.counterValue', 0)
// maybe
useHookedOnState(state => state.app?.components?.counterValue, 0)
edit: on second thought, you're probably using that string in the setter as well. dang.
Re:Show HN: Redux with a UseState Hook
by harrisonhope on Friday May 29, 2020 @11:34AM
(#23351180)
Yup, that's the "magic" part.