-
Notifications
You must be signed in to change notification settings - Fork 49.6k
Closed
Description
React version: 19.2
Steps To Reproduce
- Open the reduced test case and view the console
- Click the "Home" link (this causes
navigationType
to change toREPLACE
)
function App() {
const navigationType = useNavigationType();
// ✅ This is REPLACE after clicking the link.
console.log('render', navigationType);
const fn = useEffectEvent(() => {
// ❌ But this is always POP. It's not seeing the latest value!
console.log('effect event', navigationType);
});
useEffect(() => {
setInterval(() => {
fn();
}, 3000);
}, []);
return (
<>
<Link to="/">Home</Link>
<Outlet />
</>
);
}
// 🤷♂️ Removing `memo` here fixes the problem.
export default memo(App);
Link to code example:
https://stackblitz.com/edit/github-utjrgufd?file=app%2Froot.tsx
The current behavior
The Effect Event receives a stale value from navigationType
(POP
).

The expected behavior
The Effect Event should receive the latest value from navigationType
(REPLACE
).