Abracadabra: The Vanishing Network

Rate this content
Bookmark

The network that stands between our server and the client is what causes the most complexity in our development process. Whether it be the initial UI we generate on the server, the API calls we make as the user navigates around, or the form submissions our user makes, keeping the application responsive and up-to-date is a massive chore.

What would it be like if all of that complexity just disappeared? Freaking great, that's what it would be like. And React Server Components and Actions are what's making that possible. In this talk we'll look into how that's happening and how we can take advantage of this amazing developer experience to deliver even better user experiences.

This talk has been presented at React Summit US 2024, check out the latest edition of this React Conference.

FAQ

The speaker prefers Remix because it aligns with their preferred methodology for building apps, offering a different approach to handling server-side rendering and client-side functionality.

Pespa, or the progressively enhanced single-page app architecture, involves using frameworks like Remix to combine the benefits of server-side rendering with client-side enhancements for improved user experience.

The shift from multi-page apps to single-page apps was driven by the desire to improve user experience by avoiding full-page refreshes and reducing template duplication between the server and client.

Modern React with server components improves the process by allowing developers to write server-only logic that can be referenced in client-side code without duplicating logic, thus reducing network code complexity.

Progressive enhancement is important for ensuring that applications work for users with varying levels of JavaScript support, enhancing the user experience while maintaining backward compatibility.

The speaker suggests optimizing for change by making it easy to refactor and adapt code over time rather than over-abstracting logic into separate files.

The trade-off involves dealing with some complexity from using compiler directives, but it simplifies the integration of server and client logic, potentially reducing network-related code.

The speaker recommends using Playwright for end-to-end testing and focuses on integration tests as part of their testing strategy, aligning with the testing trophy philosophy.

The speaker took two weeks to add a checkbox due to the complexity of managing network operations and dealing with a large, complex codebase rather than the UI itself, which was simple.

Kent C. Dodds
Kent C. Dodds
32 min
19 Nov, 2024

Comments

Sign in or register to post your comment.
Video Summary and Transcription
I am so excited to share my software development experience. The talk focuses on React and the Vanishing Network, aiming to make network management disappear. It starts with the multi-page app paradigm and moves towards enhancing user experience and transitioning to single-page app architecture. The talk discusses eliminating duplication, transitioning to a JSON API, and utilizing React and user actions. It explores progressive enhancement with Remix, moving to modern React with server components, and enhancing server-client communication and UI. It also covers server-client code separation, Epic React version two, AI plugins, Next.js, trade-offs, testing, SQL queries, and optimizing for change.
Available in Español: Abracadabra: La Red Desaparecida

1. Introduction to React and the Vanishing Network

Short description:

I am so excited to be here and share my software development experience. I had an internship where I had to add a checkbox to an app. The code was complex, but the UI was easy. The job was tough due to network management. I want to make the network disappear and discuss it in this talk. It's based on a free workshop called React and the Vanishing Network.

I am so excited to be here, and I've got so much to share with you, so I'm thrilled that we don't have to do this. We just did that. So we're going to get right into story time.

When I was just getting into software development, I had an internship at a company called Domo, and we built an app that was a business intelligence app. This was BI before AI was too popular. And watch your eyes. This is the only bright slide that I have for you, but it's going to blind you. And now I can see you.

So this is the app, and I was asked as the intern to add a checkbox. It wasn't actually this checkbox because the UI looks completely different now than it did then, but we're going to imagine. I was asked to add that checkbox. Here's the code for that. It was a backbone model and view. We're going to look at this in detail. So that's our model. And then here's a bit from our view. No, just kidding. We're not going to look at that. And it actually isn't the code, either. That was ChatGBT. But it was a backbone stuff. It was a 1,000 line model, a 2,000 line base view, and a 1,000 line view that extended the base view. That's what I had to work with to add this checkbox. It took me all of, like, five minutes to add the UI for that.

But I want to know, just shout it out because I can't see if you raise your hands. How long do you think it took me to add this feature? Two sprints? A day? Two hours? Five months, OK. It took me two weeks. And I'm like the intern trying to prove myself, and I did. Yeah, I proved that I am incompetent, I guess. It was just so sad. Why do you think it took so long? Shout this out. Complexity. OK, so in general, complexity. Yeah, there was a lot of code. What specifically makes this job so complex? JavaScript. Yeah, you're not wrong. It's network management. The loading the data and doing the mutation. Adding the UI was like super fast. That was not hard. It's just an HTML template in my backbone view, but managing that network, man, that was tough. And that's what made it take two weeks. So I want to make the network completely vanish, completely disappear. And so that's why we're going to see what is happening to our network code in our applications.

The rest of my talk is based on a workshop that is completely free. You can go through the entire thing yourself. And that's what we're going to go through here. It's the React and the Vanishing Network. You can check this out later. We're going to be moving kind of quick through this.

2. Exploring the Multi-Page App Paradigm

Short description:

So we're starting with the multi-page app paradigm. We generate HTML, get a count from the database, and render it. We make a form to update the count, handle the route, convert form data, update the count, and redirect. There's minimal network code, but we moved on for better user experience. Clicking on the button causes a full page refresh, hindering quick increments for keyboard users.

So I checked it before, and you should be able to see that. If not, I am so sorry. I did my best. But yeah, we're going to start with the multi-page app paradigm where we all started. So we've got this simple app serving from the slash.

We're going to generate some HTML. So let's get a count from our database. We're going to render that count out here. And here, let's save that and make sure that we're in a good spot. Boom. Count zero. Magic. The web still works. Always bet on the web.

Now we're going to make a form so that we can update this. And so we're posting to update count. And then we have these buttons that can have a name and a value. Did you know that? That's a cool thing. So whichever one we click is what's going to be sent to the back end. So that's cool. Now if I try to click on one of those, it's not going to work because we're going to that route and we're not handling that route. So let's handle that route now. We're going to handle a post to update count. We've got our form data. We're going to convert that into a number because that goes over as a string. We're going to update the count, change it, buy that change, and then redirect because we're doing post redirect get. If you don't know what that means, then ask your elders. And we're going to decrement and increment. There we are. Awesome. It works. OK, so let's take a look at the network code. Where is the network code in here? Well, there's not actually a lot. But there is some. Some code related to the network. We've got this slash here. That's the URL. It's very much attached to the network. Our action is being defined here. So that's kind of network code too. Even our method that's related to the network. And then, of course, handling that and doing the redirect. All of that is sort of related to the network. Or pretty close. But there's really not a whole lot of network code in here. And this is why a lot of people who built apps using the multi-page app architecture really lament the way that we do things now because it really is that simple. But there's a reason we moved on from this. And the reason is user experience. So we want to have a much better user experience because right now what we're getting is a full page refresh every time we click on this. And so if I wanted to increment really quickly and I was a keyboard user, I'm going to tap, tap, increment, tap, tap, increment, tap, tap, increment.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Asynchronous UX
React Advanced 2021React Advanced 2021
21 min
Asynchronous UX
Top Content
Today's Talk covers the importance of building Asynchronous UX with React and single-page applications, providing code and UX examples. It explores data fetching, adding progress indicators, handling errors, and user-initiated actions. The Talk also discusses handling component unmounts, multiple actions, idempotency, and context loss. Finally, it touches on considerations for optimistic updates and the use of CRDT or other technologies for collaborative applications.
React Native Animations Should Be Fun
React Advanced 2022React Advanced 2022
28 min
React Native Animations Should Be Fun
This talk is about animations in React Native, specifically focusing on React Native Reanimated. It covers the use of interpolations and extrapolations in animations, animating items in a carousel or list, sticky elements and interpolation, and fluidity and layout animations. The talk provides valuable tips and tricks for creating performant animations and explores the use of math formulas for natural movements.
Remixing How We Give
Remix Conf Europe 2022Remix Conf Europe 2022
32 min
Remixing How We Give
Daphne uses Remix for their web application, benefiting from its resilience, error boundaries, cache boundaries, and progressive enhancement. Remix simplifies form submission, authorization, and validation, and allows for easier refactoring and code duplication avoidance. Next and Remix are used together, with Remix serving as the backend for the frontend and handling data aggregation. Remix provides query functions for fetching data, mutations for form data validation and API calls, and custom conventions using the handle export. Migrating to Remix resulted in smaller JavaScript files, faster navigation, and the ability to preload data and assets. The migration process took around nine months and involved mixing Next.js and Remix using Express. Hiring someone to work on Remix is easier than hiring for other frameworks.
Improve Your App Performance With Background Jobs
React Summit 2024React Summit 2024
29 min
Improve Your App Performance With Background Jobs
This is a background jobs one-on-one talk focusing on the challenges and benefits of using background jobs in software development. It explores the complexity of software development and the impact of distributed applications. The talk highlights the use of Ingest as a reliable solution for executing functions in the background and building drip campaigns. It emphasizes the importance of reliability and architectural choices in software development and discusses the features and capabilities of Ingest, including local development, handling failures, and data retrieval.
Lessons Learnt from Building Interactive React Applications
React Summit Remote Edition 2021React Summit Remote Edition 2021
35 min
Lessons Learnt from Building Interactive React Applications
Animations can enhance the user experience and provide context in interface design. Using frame and motion in React can create smooth fade-in effects and improve navigation. Optimistic updates and instant comment appearance can eliminate waiting time and improve user experience. Motion can be used in multiple ways to give context and enhance user experience. Accessibility and performance should be considered when implementing animations. Choosing the right library, such as frame of motion or React Spring, can simplify animation implementation. Animations can enhance perceived performance and influence users' perception of speed.
Performance is User Experience: Optimizing the Frontend for the Users
JSNation 2022JSNation 2022
8 min
Performance is User Experience: Optimizing the Frontend for the Users
Today's Talk discusses software performance and optimizing the frontend for the user. It emphasizes the importance of passive performance, which is a subjective measure of how well users perceive the application's performance. Techniques to improve performance include using a shared cache, HTTP2, preloading requests, and CDN. Optimizing frontend performance involves avoiding blocking the main thread, loading necessary resources first, using progress bars, and implementing optimistic patterns. It also highlights the importance of considering users' changing expectations throughout their interaction with the application.