Pending UI

πŸ‘¨β€πŸ’Ό Some of our users have complained that the UI doesn't feel responsive because after they submit their profile form, it can take a while before there are any updates and they're not sure whether they did something wrong.
This is one of the things the browser did for us before we brought JavaScript along for the party. Once we brought JavaScript along, we started doing event.preventDefault() which removed the full-page refresh, but also removed the pending UI feedback the browser shows for us. We need to add that back.
Could you give them some feedback while they're waiting for the server to respond? We want to do this specifically for when the user submits the note edit form and hits the delete button.
Remix allows you to give the user an even better experience by showing "pending UI" using the useNavigation hook. Only one transition can be happening at a time in the web (you can't go to two places at once) so that's true here as well. This means you'll need to use the information from the navigation to determine if the form is submitting or not.
Here's an example of useNavigation that should help you get a sense of the information you can get from the navigation object (πŸ“œ also check out the useFormAction hook).
export default function SandwichChooser() {
	const navigation = useNavigation()
	const formAction = useFormAction()
	const isSubmitting =
		navigation.state !== 'idle' &&
		navigation.formMethod === 'POST' &&
		navigation.formAction === formAction
	return (
		<Form method="POST">
			<label>
				Type: <input name="sandwichType" />
			</label>
			<button type="submit" disabled={isSubmitting}>
				{isSubmitting
					? `Creating ${submittedSandwichType} Sandwich`
					: `Create Sandwich`}
			</button>
		</Form>
	)
}
πŸ§β€β™‚οΈ I've created a <StatusButton /> component that has a status="pending" prop you can use for this if you like. We'll also want to disable the button when the form is submitting.
Login to get access to the exclusive discord channel.
  • general
    Epic stack using tanstack form
    wargha πŸš€ 🌌:
    https://github.com/epicweb-dev/epic-stack/compare/epicweb-dev:main...wargha:feature/tanstack-form-ex...
    • βœ…1
    2 Β· an hour ago
  • general
    Init command outdated on the EpicWeb website
    Virgile πŸ† 🌌:
    Hi everyone. I've initialized a new epic-stack project yesterday. Following instructions from http...
    • βœ…1
    3 Β· 3 days ago
  • general
    Mark as complete, resets the first time you click it.
    Daniel V.C πŸš€ 🌌:
    Not sure if anyone else has had this issue, as i've not seen anyone else talk about it, but I find ...
    • βœ…1
    8 Β· 9 days ago
  • general
    Keeping Epic Stack Projects Free on Fly – Any Tips?
    wargha πŸš€ 🌌:
    I’ve been experimenting with the Epic Stack and deploying some dummy projects on Fly. I noticed that...
    • βœ…1
    0 Β· 21 days ago
  • general
    epic stack website initial load at home page is unstyled (sometimes)
    osmancakir πŸš€ 🌌:
    Sometimes (especially when it is loaded first time on a new browser etc.) I see this unstyled versio...
    10 Β· 7 days ago
  • πŸ’Ύdata
    general
    πŸ“forms
    πŸ”­foundations
    double underscore?
    trendaaang 🌌:
    What with the `__note-editor.tsx`? I don't see that in the Remix docs and I don't remember Kent talk...
    • βœ…1
    2 Β· a year ago
  • general
    Welcome to EpicWeb.dev! Say Hello πŸ‘‹
    Kent C. Dodds β—† πŸš€πŸ†πŸŒŒ:
    This is the first post of many hopefully!
    • 18
    81 Β· 2 years ago
  • πŸ’Ύdata
    general
    πŸ“forms
    πŸ”­foundations
    Creating Notes
    Scott 🌌 πŸ†:
    Does anybody know in what workshop we create notes? I would like to see the routing structure. So fa...
    • βœ…1
    2 Β· 3 months ago
  • πŸ”­foundations
    πŸ’Ύdata
    general
    πŸ“forms
    πŸ”auth
    Thank you for the inspiration
    Binalfew πŸš€ 🌌:
    <@105755735731781632> I wanted to thank you for the incredible knowledge I gained from your Epic Web...
    • ❀️1
    1 Β· 3 months ago
  • πŸ”­foundations
    git push returns 400
    mohdelle 🌌:
    when i try to start a fresh epic stack project and push to remote it's going to an error. anyone els...
    • βœ…1
    3 Β· 4 months ago
  • general
    npm install everytime I setup a new playground
    Duki 🌌:
    Is it normal that I have to run `npm install` in my playground directory, everytime I setup the play...
    • βœ…1
    2 Β· 5 months ago
  • πŸ”­foundations
    Progessive Enhancement - React .map
    Scott 🌌 πŸ†:
    I'm reviewing Foundations --> Scripting --> Scripts. I'm wondering how the `.map` works (iterating...
    • βœ…1
    1 Β· 6 months ago
  • πŸ”­foundations
    Parent Data - SEO - Typescript concept help
    remich 🌌:
    I'm relatively new to TS, and I can see the value that Kent is talking about with the second argumen...
    • βœ…1
    1 Β· 8 months ago
  • πŸ’Ύdata
    πŸ“forms
    πŸ”­foundations
    Reviewing foundations, Mutations, Actions
    silvanet πŸš€ 🌌:
    Forgive me for this. I went over the file size limit. I don't want to sign up for being able to exce...
    • βœ…1
    2 Β· a year ago
  • general
    Migration to Vite: Server-only module referenced by client
    Fabian 🌌:
    Hi, I'm working on migrating to Vite following the remix docs (https://remix.run/docs/en/main/guides...
    • βœ…1
    1 Β· 8 months ago
  • πŸ”­foundations
    Styling 05 workshop error: Expected component `CodeFile` to be defined
    jocosage 🌌:
    Is this error intended behaviour, it doesn't look so as in the git repo there seems to be instructio...
    • βœ…1
    3 Β· 6 months ago
  • πŸ”­foundations
    Foundations Review
    Baghira 🌌:
    I finished the foundations workshop. I liked the SEO part and error handling part. Remix built-in to...
    • βœ…2
    1 Β· 7 months ago
  • general
    Remix Vite Plugin
    Binalfew πŸš€ 🌌:
    <@105755735731781632> Now that remix officially supports vite (though not stable) what does it mean...
    • βœ…1
    3 Β· a year ago
  • general
    πŸ”­foundations
    Solutions video on localhost:5639 ?
    quang πŸš€ 🌌:
    Hi, so I'm having a hard time navigating (hopefully will be better with time) The nav on epicweb.de...
    • βœ…1
    9 Β· a year ago
  • πŸ”­foundations
    Progressive Enhancement & Client Side Scripting
    Chwizdo 🌌:
    I'm currently just starting at foundations | scripting part, and until now, I've heard KCD mentioned...
    • βœ…1
    4 Β· a year ago
  • πŸ”­foundations
    Unable to push my changes to Github
    Sachin Purohit 🌌:
    When trying to push changes, I am getting the below error- remote: fatal: did not receive expecte...
    • βœ…1
    3 Β· 9 months ago
  • general
    Epicshop is now social and mobile friendly!
    Kent C. Dodds β—† πŸš€πŸ†πŸŒŒ:
    I'm excited to announce that now the Epic Web workshops are mobile friendly! https://foundations.ep...
    • πŸŽ‰2
    0 Β· 10 months ago
  • πŸ”­foundations
    How to fetch data on client (e.g. Combobox)
    QzCurious 🌌 πŸš€:
    After learning from epic web, I'm really into SSR data fetching pattern. I'm now doing SSR all of m...
    • βœ…1
    2 Β· 10 months ago
  • πŸ”­foundations
    @remix-run/react vs @remix-run/node
    mustak πŸš€ 🌌:
    Module: Search Engine Optimization Exercise: Meta Overrides There are 2 different imports for type ...
    • βœ…1
    2 Β· 10 months ago
  • πŸ’Ύdata
    πŸ“forms
    πŸ”­foundations
    How can I do this?
    silvanet πŸš€ 🌌:
    Viewing the Intro (from the Workshop) for Mutations, the course has an embedded video where Kent exp...
    • βœ…1
    3 Β· a year ago
  • πŸ”­foundations
    remix flat routes
    mustak πŸš€ 🌌:
    Can someone give me a quick explanation of the following: ```markdown ## underscores with files _fi...
    • βœ…1
    2 Β· a year ago
  • πŸ”­foundations
    How to launch VS Code editor from File links in app using wsl2?
    mustak πŸš€ 🌌:
    I've tried setting environment variables in .env: ```js KCDSHOP_EDITOR=code ``` and ```js KCDSHOP_ED...
    • βœ…1
    5 Β· a year ago
  • πŸ”­foundations
    Meta function not being called
    juliano.brasil 🌌:
    Hi. I'm checking the assets on the foundations module, and something is somehow not working for me (...
    • βœ…1
    7 Β· a year ago