Skip to content

Commit

Permalink
REACT: Corrected the inifinite reference issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Pckool committed Jul 8, 2022
1 parent 4521e43 commit 7fbf72f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/plexus-react/src/usePlexus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function usePlexus<V extends Watchable[]>(deps: V | [] | Watchable): Plex
const depsArray = holding.current
return concurrentWatch(onChange, depsArray)
},
[deps, ...holding.current.map((dep) => dep.value)]
[deps]
)
const fetchValues = useCallback(() => {
const depsArray = holding.current
Expand All @@ -50,7 +50,7 @@ export function usePlexus<V extends Watchable[]>(deps: V | [] | Watchable): Plex
snapshot.current = compSnapshot
}
// console.log("usePlexus", id.current, "fetchValues", snapshot.current, compSnapshot)
if (snapshot.current !== compSnapshot) {
if (snapshot.current === compSnapshot) {
return deps.value! as PlexusValue<V>
}
snapshot.current = compSnapshot
Expand Down Expand Up @@ -89,7 +89,7 @@ export function usePlexus<V extends Watchable[]>(deps: V | [] | Watchable): Plex

// return the array and give it the correct type
return returnArray.current
}, [deps, ...holding.current.map((dep) => dep.value)])
}, [deps])

return useSyncExternalStore(
// Subscription callback
Expand Down

0 comments on commit 7fbf72f

Please sign in to comment.