Pending UI

Loading "Pending UI"
πŸ‘¨β€πŸ’Ό Sometimes our users are on slow networks so we should give them good feedback when they interact with our application.
To be able to do this effectively, we need a few things:
  1. Our transitions should take place within a useTransition startTransition
  2. The location to remain unchanged until the transition is complete
  3. We need a nextLocation state so we can determine what part of the location is changing
We've already got our transition wrapped in a startTransition, but this is the global one from react. We need to use one from useTransition instead so we get access to the isPending state.
Then we'll change our location to be a nextLocation and then use useDeferredValue to get the location so that it remains unchanged until the transition is complete.
Then we can add the isPending and nextLocation to our router context and use that to determine pending states for our UI.
πŸ§β€β™‚οΈ You're going to want to use the parseLocationState utility I made for this one. Here's how it works:
import { parseLocationState } from './router.js'

const location = '/abc123?search=starship'
const state = parseLocationState(location)
// ^ { shipId: 'abc123', search: 'starship' }
You can use that to parse the current location and the next location. If the part you care about is different then you know you can show a pending state.
Login to get access to the exclusive discord channel.
  • General
    Failed to fetch dynamically imported module...
    FacuPerezM:
    I am getting this error out of nowhere, in the 'test' tab inside the Workshop app. ``` Failed to f...
    1 Β· 10 hours ago
  • General
    Runninng Learning app on iPad?
    marcus_polonus πŸš€:
    Hi all, Did anyone managed to setup learning app on iPad? I tried to use codesandbox, but when I am...
    0 Β· a day ago
  • General
    Clicking an exercise file launch VIM instead of VS Code
    DBattou πŸš€:
    I started going through the workshops, everything is setup and working fine except for opening a fil...
    • βœ…1
    2 Β· 5 days ago
  • General
    Epicshop not saving the video resolution
    Toni πŸš€:
    Playback speed and caption settings are saved, but the video resolution always defaults to auto. Is ...
    • βœ…1
    7 Β· 2 days ago
  • General
    Launch editor error: spawn code ENOENT
    Andrew Elans 🌌 πŸš€:
    Clicking index.html gives this error in VS Code. Both from Chrome and Safari. Anyone?
    • βœ…2
    3 Β· 21 hours ago
  • General
    Welcome to EpicReact.dev! Say Hello πŸ‘‹
    Kent C. Dodds β—† πŸš€πŸ†πŸŒŒ:
    Welcome to the first of many posts in the EpicReact.dev channel! Take a moment to introduce yourself...
    • πŸš€5
    34 Β· 16 hours ago