Skip to content

Comment on Show HN: Redux with a UseState Hookparent

Comments

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.

Yup, that's the "magic" part.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.