You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
isValidating change only triggers first hook in component tree to render
Description / Observed Behavior
It seems that if multiple components use useSWR(someKey), a change to isValidating only triggers the first of these components in the tree to rerender.
Expected Behavior / Repro Steps / Code Example
In this example, I have 3 components that all use useSWR('/api/things'): ThingsList, ThingsListError, and ThingsRefreshButton, but ThingsRefreshButton comes first in the component tree and is the only one receiving the re-render when the value changes. The expected behavior here should be that if the value of isValidating changes, all these components should receive a re-render trigger.
Relevant code is provided below:
Additional Context
SWR version: "0.2.3"
The text was updated successfully, but these errors were encountered:
@blackarctic thanks for noticing this issue. current implementation of swr have isValidating in the state of each hook, so in the case they're not consistent and lead to the bug. ideally the isValidating state should bind with key, then return value could be recitified.
@huozhi Thanks for the response. I would be happy to try to contribute here. I would just need a bit to get up to speed with what is happening in the codebase.
isValidating change only triggers first hook in component tree to render
Description / Observed Behavior
It seems that if multiple components use
useSWR(someKey)
, a change toisValidating
only triggers the first of these components in the tree to rerender.Expected Behavior / Repro Steps / Code Example
In this example, I have 3 components that all use
useSWR('/api/things')
:ThingsList
,ThingsListError
, andThingsRefreshButton
, butThingsRefreshButton
comes first in the component tree and is the only one receiving the re-render when the value changes. The expected behavior here should be that if the value ofisValidating
changes, all these components should receive a re-render trigger.Relevant code is provided below:
Additional Context
SWR version: "0.2.3"
The text was updated successfully, but these errors were encountered: