Skip to content

Commit 9bcd66a

Browse files
committed
client: Fix spurious reloading on entry activation
When an article is activated, its `id` will be appended to URL. `NavigateFunction` depends on `Location` so when the URL was updated, the `useEffect` callback would be triggered due to the dependency change. The callback would then reload the entries list. Even worse, when using the unread filter, the just activated entry would disappear. However, we should not actually need to pass the `navigate` function: The `Location` is really only a dependency so that `pathname: null` can use the current location, https://github.com/remix-run/react-router/blob/a3e4b8ed875611637357647fcf862c2bc61f4e11/packages/react-router/lib/router/utils.ts#L1267 and we always do set a string `pathname`. And the other dependencies appear to be static: https://github.com/remix-run/react-router/blob/a3e4b8ed875611637357647fcf862c2bc61f4e11/packages/react-router/lib/hooks.tsx#L292-L296 This got broken in 88deede.
1 parent 7b6af95 commit 9bcd66a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

client/js/templates/EntriesPage.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,9 @@ export function EntriesPage({
324324
abortController.abort();
325325
};
326326
}, [
327+
// navigate is intentionally omitted
328+
// to prevent reloading when path is replaced
327329
configuration,
328-
navigate,
329330
params.filter,
330331
currentTag,
331332
currentSource,

0 commit comments

Comments
 (0)