How to add data-binding delays in reagent?

I’d go for the setTimeout solution together with component-local data:

  • store the state of the input field in a local atom
  • on every on-change event, register a handler with setTimeout to update the global atom.

You’d need to de-register the old handler in on-change as well, and you’d also need to de-register it on correctly. I’m not sure if it’s enough to do that in the on-blur, or if you’d need to use the component-will-unmount life-cycle fn. I think I’d go for the latter. You can store the registered handler id in the local atom as well.

1 Like