Skip to content

Commit 5036ff3

Browse files
committed
Added small ref comment.
1 parent 89cb44f commit 5036ff3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

packages/react/src/hooks/watched/useWatchedQuery.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export const useWatchedQuery = <RowType = unknown>(
1616
): QueryResult<RowType> | ReadonlyQueryResult<RowType> => {
1717
const { query, powerSync, queryChanged, options: hookOptions, active } = options;
1818

19+
// This ref is used to protect against cases where `queryChanged` changes multiple times too quickly to be
20+
// picked up by the useEffect below. This typically happens when React.StrictMode is enabled.
1921
const queryChangeRef = React.useRef(false);
2022
if (queryChanged && !queryChangeRef.current) {
2123
queryChangeRef.current = true;

0 commit comments

Comments
 (0)