Skip to content
Discussion options

You must be logged in to vote

This looks like a bug in react-router to me. I found a work-around that solves the issue. I think that if react-router is rendering correctly, then my work-around should have no effect.

The work-around is to import and use the useNavigation hook, and short-circuit the rendering of Contact if navigation.state is not 'idle':

  1. Import useNavigation hook:

    import {
      // ... existing imports
      useNavigation,
    } from "react-router-dom";
    
  2. Invoke useNavigation in Contact:

    export default function Contact() {
      const { contact } = useLoaderData();
      const navigate = useNavigate();
      const navigation = useNavigation()
      // ...
    }
    
  3. Short-circuit rendering if not idle

  // ... existing code
  if (n…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by SomervilleTom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant