State Management · Senior · Question 41 of 75
How do you prevent a loader from re-running after every action on the page?
- ✓Correct answer: Export
shouldRevalidatefrom the route and returnfalsewhen the data can't be affected - 2Wrap the loader in
useMemo - 3Return cache headers from the action
Explanation
By default all active loaders revalidate after an action, which is safe but can be wasteful. shouldRevalidate({ formAction, currentUrl, nextUrl, defaultShouldRevalidate }) lets you opt out selectively.