Skip to content

Commit

Permalink
client: Fix spurious reloading on entry activation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jtojnar committed Jan 9, 2025
1 parent 7b6af95 commit 9bcd66a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion client/js/templates/EntriesPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,9 @@ export function EntriesPage({
abortController.abort();
};
}, [
// navigate is intentionally omitted
// to prevent reloading when path is replaced
configuration,
navigate,
params.filter,
currentTag,
currentSource,
Expand Down

0 comments on commit 9bcd66a

Please sign in to comment.