Updating value passed to a hook after render
Unanswered
ryanycw.eth posted this in #help-forum
I've initiated a hook inside a component,
https://github.com/AlibudaLab/nouns-habit-builder/blob/e6490b1a64627db3bcd67cd22f5d2cc82b718d8a/web/app/habit/checkin/components/checkinRun.tsx#L44-L58
However, the hook depends on some value that we set after a button is clicked.
https://github.com/AlibudaLab/nouns-habit-builder/blob/e6490b1a64627db3bcd67cd22f5d2cc82b718d8a/web/app/habit/checkin/components/checkinRun.tsx#L68-L110
Thus the issue is that when the onCheckInTx is executed, the hook won't be using the newest value that was updated in onCheckInTx.
https://github.com/AlibudaLab/nouns-habit-builder/blob/e6490b1a64627db3bcd67cd22f5d2cc82b718d8a/web/app/habit/checkin/components/checkinRun.tsx#L110
Is there any better pattern or helpers for such use case, like maybe useContext?
https://github.com/AlibudaLab/nouns-habit-builder/blob/e6490b1a64627db3bcd67cd22f5d2cc82b718d8a/web/app/habit/checkin/components/checkinRun.tsx#L44-L58
However, the hook depends on some value that we set after a button is clicked.
https://github.com/AlibudaLab/nouns-habit-builder/blob/e6490b1a64627db3bcd67cd22f5d2cc82b718d8a/web/app/habit/checkin/components/checkinRun.tsx#L68-L110
Thus the issue is that when the onCheckInTx is executed, the hook won't be using the newest value that was updated in onCheckInTx.
https://github.com/AlibudaLab/nouns-habit-builder/blob/e6490b1a64627db3bcd67cd22f5d2cc82b718d8a/web/app/habit/checkin/components/checkinRun.tsx#L110
Is there any better pattern or helpers for such use case, like maybe useContext?
1 Reply
Bumping this up to see if anyone can shed some light on this