State Management · Middle · Question 48 of 75
How do you redirect from an action after creating an item?
- ✓Correct answer: Return (or throw)
redirect('/items/' + id)from the action - 2Call
window.location.href = ...inside the action - 3Call
useNavigate()inside the action
Explanation
Loaders and actions run outside components, so hooks aren't available. redirect creates a response the router follows. Hooks like useNavigate work only in components.