-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Description
Currently, useSubscription does not recreate or resubscribe when the subscription vector changes due to updated parameters.
If a subscription is created with parameters and those parameters change, the hook continues using the old subscription instead of unsubscribing and subscribing with the new parameters.
Steps to reproduce
Use useSubscription with a parameterized subscription:
const inputItems = useSubscription<BaseInputItem[]>([SUB_IDS.BASE_INPUT_ITEMS, baseId])Change baseId to a different value.
Observe that the subscription is not recreated for the new baseId.
Expected behavior
When the subscription vector changes, for example when baseId changes:
the hook should unsubscribe from the previous reaction
a new reaction should be created for the new subscription vector
the hook should resubscribe and provide the value for the new parameters
Actual behavior
The hook keeps the existing subscription and does not resubscribe, so updates for the new parameters are not received.
Impact
This makes parameterized subscriptions unreliable in React components, as changing parameters does not trigger resubscription and can lead to stale data.
Possible solution
Update useSubscription so that it reacts to changes in the subscription vector and properly cleans up and recreates the underlying reaction when parameters change.