chantastic.fm

85: Michael Jackson on React Router v6 and Empathy in Open Source

Episode 85 · March 12, 2020 · 01:31:18

Hosted by chantastic · With Michael Jackson

Sponsored by Infinite Red

Download MP3 · Jump to transcript

This week we chat with Michael of React Training and learn everything we need to know about React Router v6 — what's in store, how to update, and what he's learned about empathy in the process.

Featuring

React Suspense Course

Get up to speed fast on React Suspense in my crash course at reactsuspense.com!

Links

Sponsors

Infinite Red

In over your head with a React or React Native app? Infinite Red can help. They're React Native core contributors who've been designing, building and shipping apps for over 10 years. reactpodcast.infinite.red

Transcript

[00:00:00] Michael Chan: This is React Podcast. I'm Chantastic. This week we chat with Michael Jackson of React Training and learn everything we need to know about React Router v6. What's in store and how to update. Are you working on a React Native app? How's it going? Are you in over your head? Infinite Red can help. They've helped hundreds of companies just like yours build beautiful, functional mobile They're not just experts in React Native, they're contributing to core, maybe built a feature you're using right now experts in React Native. They've taught tens of thousands of developers through open source and their annual React Native conference, Chain React. As a listener of this show, you can get 2 free tickets to Chain React in 2021 when you start or refer a new project. Visit reactpodcast.infinite.red to get started and build a beautiful app today. In today's episode, Michael and I talk about React Suspense, and I realized I've never told you about my React Suspense course. Shame. If you wanna learn about React Suspense but haven't known where to start, let me help you out. Visit reactsuspense.com for my gentle 1-hour introduction to React Suspense. It's not nearly as scary as I thought it would be, and I walked away with a huge sense of accomplishment after using all of the React Suspense APIs. Again, the URL is reactsuspense.com. Easy enough for my 1-hour crash course into React Suspense. Now, into the show.

[00:01:41] Michael Jackson: Blast off!

[00:01:44] Michael Chan: Welcome back to React Podcast.

[00:01:46] Michael Jackson: Dude, feels so good to be back.

[00:01:48] Michael Chan: You started this whole thing in motion.

[00:01:50] Michael Jackson: No, I- it's- yeah, no, the React Podcast has been a- it's really been like a group effort, right? Because you were doing it, then I was doing it, now you were doing it, Jed was doing it for a little bit.

[00:02:02] Michael Chan: Yeah. It's it's a community thing. Community thing.

[00:02:05] Michael Jackson: It's organic.

[00:02:06] Michael Chan: No GMOs.

[00:02:08] Michael Jackson: Certified organic podcast.

[00:02:10] Michael Chan: Um yeah, what it is good to it's good to have you back on because I love talking with you and uh it's it's been a minute. We haven't had your voice on the show for a while and I think it's it's time.

[00:02:21] Michael Jackson: It has been a minute. I almost yelled in the background when you did that episode with Sunil at React Conf because I was there and I was almost like, Hey everybody, I'm here! But I, I restrained myself. But yeah, it's, it's, it's been a little while. It's good to be back.

[00:02:36] Michael Chan: Well, glad to have you back on. It feels right. I feel like, uh, we, we need to do more of these. But

[00:02:41] Michael Jackson: yeah, man,

[00:02:42] Michael Chan: we, um, we've been wanting to talk on the show about React Router for a super long time, um, because there's so much happening there in response to like hooks and suspense and all of these things that everyone's been talking about for a really long time. And I feel like um you've been working on solutions in the router to make all that great for everybody. Um oh yeah. So let's- what have you been up to?

[00:03:08] Michael Jackson: Yeah, oh my gosh. So welcome to my cave, first of all. This is uh being recorded in my home office. And this is where I have spent oh the vast majority of my waking life for the last like several months. Um So I I began work on I began work on React Router version 6 uh probably back in October. I want to say like early October. Ryan and I— uh people who might not know, people who might be new to me, uh my my business partner, Ryan Florence, and I, we run a business called React Training, uh reacttraining.com, where we go around and we train people on uh on learning React. And uh we've recently kind of been scaling up the business. So we hired a few people to kind of help us with that effort. We also hired uh software developer, um Chance Strickland, who is down here in San Diego as well. And he's helping us build some software.

[00:04:05] Michael Chan: His last name isn't The Dev?

[00:04:06] Michael Jackson: No, it's it would be sweet though. It'd be sweet, Chance The Dev.

[00:04:10] Michael Chan: I gotta talk with him about that.

[00:04:11] Michael Jackson: Um yeah, he he's just people people always mix him up with Chance the Rapper. He's like, 'cause he had that avatar for a while.

[00:04:18] Michael Chan: The avatar with the 3 on it.

[00:04:19] Michael Jackson: Yeah, yeah, it was it was so killer. So we hired Chance, we've been working with Chance, and when we hired him to work on ReachUI, which is another open source project that that we work on at React Training, it kind of- and and we hired these instructors to do the trainings, it really kind of freed me up towards the end of last year for uh for a much needed uh React Router uh refresh. So uh so I I dug in in early October, and the place where I started was actually in the history library. So If you ever use React Router, you might be familiar with our main dependency, which is the history package, uh which I completely rewrote from scratch in about a month. So the the the idea behind that package is it is a— uh it's just it's just this thin little layer around, you know, the browser history. We've also got like a a memory implementation. We've also got a a hash history implementation. So basically we give you a a history stack uh in several different environments depending on what you need. Uh so-

[00:05:28] Michael Chan: Now what is- I'm I'm gonna interrupt you there just for a second. So for anyone who's not familiar with the package, like what is the necessity of a history library, right? Like what are the deficiencies in, I guess, just the browser-

[00:05:41] Michael Jackson: Great question.

[00:05:42] Michael Chan: —that requires a history library?

[00:05:44] Michael Jackson: Yeah, yeah, great question, great question. So, uh so the idea of of a history library is that, you know, you're most people listening are probably familiar with using the browser. You've got the back and the forward buttons. Um, and so that is, you know, as you're browsing around the web, you're clicking links, uh, new entries appear in the history stack. So, you know, if you ever look at, you know, the the window.history.length, you'll see how many items are in that stack. So as you're browsing around, uh, these new items get added constantly. So, uh, there are a few you know, as the web has sort of evolved, uh this idea of, you know, building purely client-side apps became popular quite a while ago. And, um, and the, uh, pushState and, uh, replaceState and popState APIs were added to the web.

[00:06:35] Michael Chan: As a means of like telling the browser like, hey, this is, this is a new URL, even though like we didn't navigate to it, we're here now.

[00:06:42] Michael Jackson: Absolutely. Yeah. Yeah. So these, these APIs basically let you update the address bar and push a new entry into the history stack without causing a full page refresh, which was brand new, right? Because if you if you say window.location.assign and put a URL in there, well, now the browser is gonna go and try and fetch that URL from the server. But if you say window.history.pushState, uh you can update the URL and the browser is not gonna it's not gonna sweat it. It's not gonna go and and You know, try and fetch a new thing from the server. Which is great for purely building purely client-side apps. It's exactly what you want. Um, in the past, uh, and still some apps do this today, you can kind of fake it by uh updating just the window.location hash portion of the URL. Um, which is supposed to be used for like in-page navigation on the web, but some people used it to uh to to to build like a a single-page app kind of functionality. Uh, but but pushState and and replaceState are definitely the the kind of modern way to do it.

[00:07:44] Michael Chan: Is that like the hash bang era?

[00:07:46] Michael Jackson: Yeah, that was the hash bang era. Was when yeah, Google would say like, hey, if you have a hash bang in your URL, then we will um we'll we'll index it and treat it just like a you know it's like a normal server rendered page. Um so so yeah, so that was— um and and then there's also the popstate event. So the popstate event is how you can listen for when somebody like clicks the back button or goes up and manually fiddles with the URL. Um, you know, if if they if it doesn't cause a full page refresh, if they're navigating within the portion of the stack which was uh pushed client-side, uh then uh then you'll get a popstate event. Yeah. And you'll you'll know, okay, the URL changed. So, and so the the way React Router uses that is React Router uses that to know what do we show on the page, right? Because the we need to be in sync with the current URL. Um, so the so the history library is kind of like the kind of like the core dependency of uh of React Router. And so that, like I said, I was working on that like for about a month in October, um, and got that kind of wrapped up. And that's been in beta ever since because I don't want to push it final until we get React Router final. And I just want to kind of push them over the line at the same time.

[00:08:59] Michael Chan: Sure, sure. What was it like? What were some of the things that you uh wanted to do in the rewrite?

[00:09:04] Michael Jackson: Yeah, thank you for asking. So the in the rewrite, um, so it's been a it's been a while since that library was— so it's been a while since we pushed version 4. So this is History v5. And the the main thing I wanted to do was update uh the the the uh browser, the minimum browser dependency, right? So our minimum dependency right now is IE 11. And then everything else is evergreen browsers. Nice. You know, Edge, Chrome, Firefox, whatever. Which is uh which is really, really nice because once you can ditch a lot of those old browsers, then you can ditch a lot of old code and a lot of old hacks. Um and so the the history library, actually, we we um we actually got it way, way down in size. It's it's less than half as large as it used to be.

[00:09:55] Michael Chan: Interesting.

[00:09:56] Michael Jackson: And it also has an additional feature that it didn't used to have, which I think is a really, really cool feature. So, so the History Library has always had this blocking feature. And the block feature is basically a way for you to block navigation. So you can say, if somebody's on a page, they've maybe filled out the form halfway, and then they will like click a link or they click the back button or whatever, you can you can put up a prompt to say, "Hey, uh, you've entered stuff here. If you navigate away, it might not be here when you get back. Um, are you sure you want to leave?" Right? And uh, or or you know, or maybe you just click a link out, you know, to go to another site. And and it had always been implemented in kind of a hacky way because we we could never depend 100% on browsers having um- The pushState capability. Sure. So the pushState API is actually an amazing, like, very, very underutilized API on the web. Um, basically lets you tie a blob of state, could be anything, to a URL. Right? So, uh, so in our case, what we're doing is we're using it to tie uh an index to the current URL. And so, um I actually made a video about this. Maybe we'll include that in the show notes. I made a video about this back in November. But the the navigation blocking functionality in the history library now is pretty solid. It's it's a lot lot better than it was. There's probably still like some very, very tiny edge cases, but it's a lot lot better than it was. And that's actually gonna be the foundation of building out the prompt It is the foundation of building out the prompt functionality in React Router. So in React Router, you can say, you can render like a prompt component. And uh or or you could even you even have access to use uh that we have a use blocker hook, which uh basically lets you set up any function that you want um as a callback to, um you know, to when the navigation is blocked, you can run some code there and maybe you can show a custom dialog or prompt if you want to. But it's a really, really powerful piece of functionality that um the the current web history APIs do not make it very easy at all uh to implement. So what the so it's so we kind of had to work around um uh some shortcomings in the current web history API.

[00:12:28] Michael Chan: Yeah, yeah. That's awesome. I I imagine that there's quite a bit of code about the internet um handling that specific use case of like, hey, like I'm leaving this modal, but like I either want to like retain state or tell the user like that is about to disappear. So to have that in a first-class way in React Router sounds awesome.

[00:12:48] Michael Jackson: Yeah, absolutely. And and and it's, you know, it's it's very, very possible that you would have, you know, missed some edge case or whatever. And so it's really nice to just be able to wrap it up and say like, okay, here's a function that I want to run when you block some navigation. Um, and to be able to rely on it, even, you know, whether it's uh whether it's you know, navigating within the single page app or navigating to a completely separate domain and doing a full page refresh, um, it's gonna work the same either way. So it's, it's really nice.

[00:13:20] Michael Chan: Wow. So you got, so October, you you get some, you carve out some free space. You don't have to travel the world as much, like doing React trainings. You're like, hey, I'm gonna, I'm gonna focus up on uh React Router. We got to get history in the right place first. You cut it in half by getting rid of some of the polyfills and uh You know, support older browsers, all that garbage you don't need anymore, make it more stable. Um, and then, uh, but you, you haven't quite put that out yet because you want to put it over the line with React Router v6.

[00:13:51] Michael Jackson: Yeah, they're both gonna go final together.

[00:13:53] Michael Chan: Cool. So what are some of the things that- so now that you've kind of focused all your attention on React Router v6, let's talk about like what's in that.

[00:14:00] Michael Jackson: Yeah, so the- so React Router v6, it was interesting. I was like I was like, okay, so I took about a month on this history library, like I'll probably take another month and React Router will be done, right? So so I started working on it in like late October, I started like making some commits. I'm like, yeah, I'm gonna be done by Thanksgiving, no problem. I mean, it's my full-time gig, like how hard could it be, right? So so I'm working on it, working on it, working on it, and like Thanksgiving is drawing closer and um People who follow me might know that I I kind of struggle a little bit with some anxiety. So when I set a goal for myself, like, oh, I'm gonna I'm gonna ship React Router by Thanksgiving, and Thanksgiving just comes and goes right by, and like nothing is shipped, nothing is even like close to being shipped, I'm starting to like be like, oh my gosh. It's never happened. Like I'm a terrible coder. Like what is going on? Why am I even doing this? I hate this. Christmas comes and goes, it's January now. I'm like, what is going on, right? So, so, um, so the- so anyway, I finally pushed the alpha on January 31st after working like, like, I think it was like 2 solid weeks that I like didn't shower, I didn't go outside. I was like, I'm just gonna work on this router thing until this is finally done. So January 31st, I think I pushed the the alpha, but it was a challenge. The idea was- see, the idea was was fairly simple. It was new version of React Router requires React 16.8. So, we're gonna use hooks in React Router. And then the other major thing was- well, so we wanted to fix a bunch of the warts with React Router version 4 and 5. And I also wanted to merge in sort of the best parts of Reach Router, which is a router that Ryan built a couple years ago when we weren't actually working together at the time in 2018. He went and built a separate router that was kind of built on some of the ideas of around Suspense.

[00:16:11] Michael Chan: Sure. And it was kind of it was kind of like this this fresh take in like a post-hooks announcement kind of world.

[00:16:18] Michael Jackson: Yeah, yeah, yeah, yeah, yeah. When he built that, he was thinking like, okay, so we've got hooks now and we've got Suspense now. And uh and he wasn't working on React Router at the time, so he didn't have a lot of the like core users of React Router that he had to support. So it was it was kind of like a nice greenfield project for him. And he did he you know uh experimented with a couple of things, like like had this focus management API in there and um you know a couple of of ideas. And uh some of the ideas were turned out to be really, really great. Some of the ideas uh didn't quite shake out, uh which is fine. And so, so basically what I what I was trying to do in this React Router v6 was like figure out, okay, which ones are the ideas that we really, really want, that we really like, and incorporate those. And then I also had to think about um everybody who's on version 5 or, you know, 4. How are we gonna provide a nice smooth upgrade path for them to v6? Because when we released version I think it was 2017, it was January 2017. Yeah. It was like 3 years ago. Yeah. When we released version 4, it was a pretty big shift from uh from version 3, and and there was a lot of upgrade pain. In fact, there are still people who are on version 3, and my hope is that we can get a lot of the people who are on version 3 onto version 6 because it includes um a lot of the best parts of version 3, Uh, we should be able to get the people who are on version 4 or 5 onto v6 as well, because it's not a super huge upgrade path from there. Um, and we should be able to get the people who are using Reach Router onto v6 as well. So, this is kind of- we're trying to get like 3 different groups of people who built apps on React or Reach Router onto v6, which we believe is the best ideas of like all of them combined.

[00:18:07] Michael Chan: Yeah. So, that's that's something that I think a lot of people don't think about when they think about a project like React Router is that it's not just the current permutation and the features that you want right now, but there's so much history. And like, not, not in a punny way and not in a library way, but like, there's, there's so much history. There's people who are on, you know, 3 versions back of this thing. Yeah. And, um, providing a migration path is critical because, like, you know, as, as you know, there's, there's people who are like, well, you know, the, the next thing doesn't do the thing that I want, so I'm just gonna use this for forever. And you always run that risk every major version you release. Um, so tell me a little bit more about like kind of how you've been thinking through the migration path. Is it kind of like, do you have like this like mental test framework for like, oh, it's gotta do all of these things before we can, you know, kind of think of it as done?

[00:19:02] Michael Jackson: Yeah, absolutely. So the I think I just I want to talk a little bit about empathy. And I think the empathy in software is um is incredibly important. Because software that is not going to help people, that is not going to make people's lives better, is really just like pointless. You know, like you you should really reconsider what you're doing if you're not thinking about the people who are going to be using your software. And so um So in building React Router v6, you know, when we built v4, and v4 was actually built and like pushed out very, very quickly, and because we were very excited at the time about things that we had learned about using React and ways that we had learned to use React, which were, we thought, very transformative to the way that people were going to think about it.

[00:19:54] Michael Chan: And for context, v4 was like the, the render props

[00:19:58] Michael Jackson: Yeah, v4 was render props, v4 was like just elements.

[00:20:02] Michael Chan: Yeah.

[00:20:03] Michael Jackson: Right? Which um was a very kind of groundbreaking idea at that time. I think it is a lot of— uh I think it still kind of is in React. We said, you know what, v4 is just just components, just elements. And a lot of people looked at that and were like, wait, you're routing with using React elements? Like you don't have a config object or something? Because usually people think about routing as like You know, you set up your Express config or your Nginx config or whatever, and you set it all up sort of ahead of time. Um, but, you know, we're building a router for React, which is a highly dynamic, stateful UI framework. And when we made our route objects actual elements in this dynamic, uh, environment, I think a lot of people, it didn't really click with them. Like, well, what does that mean? Right? But we unlocked a lot of really cool things. You can do a lot of cool things when it's dynamic, right? Like code splitting becomes so easy when everything's dynamic, right? Like if if my routes are defined as elements, then code splitting a React Router app is the exact same as code splitting any other React app. Because React apps are built out of elements. And routes are elements. So You know what I'm saying? So code splitting becomes incredibly easy uh taking that approach. Um there are other things like, you know, like like how do I, um you know, if if I'm if I'm, you know, doing a a nested sort of routing situation or I or I need like like dynamic routes to appear because I don't even know what routes are available until I get some data. You know, I mean those, uh so it's like I actually have a situation like that in uh Unpackage where you know, it's it's basically a file browser. And so if you're looking at a directory, you know, okay, here's the directories that I've got and here's the files here, but I don't really know or care how deep the directory tree goes when I'm looking at this page, right? It's only after I click on another directory and I get there that those routes even become available.

[00:22:09] Michael Chan: Like, how do you how do you build a static route machine for npm?

[00:22:14] Michael Jackson: Yeah, no, you can't. It's impossible, right? So so dynamic routing really is the only way to to uh uh uh approach a problem like that. So So when we went full-on dynamic routing in React Router 4, I'm just getting back to this empathy conversation, uh it was so foreign to a lot of people. We were very excited about it, obviously, but it was so foreign to a lot of people that a lot of people just said, you know, I I don't I don't get this. I don't grok this. Um I I I think I'm just gonna stay on v3. And we've actually maintained v3 for the last 3 years for these people. We've been shipping v3. We have a contributor who's actually really great at this. His name is Tim Dorr, and he's been helping us support those people who are still on v3. Um, but but yeah, the truth is just some people weren't able to make the leap, whether it was conceptually they weren't able to make the leap or just they just had other better things to work on. Um, and so uh so in building v6, I didn't wanna- Because because we've had this, we had another huge conceptual shift in React.

[00:23:19] Michael Chan: Yeah.

[00:23:20] Michael Jackson: Uh since v4 or v5. By the way, anybody listening, v4 and 5 are the exact same version of React. There's a weird thing that, it was a weird npm dependency issue with the caret in the package.json. And so we had to release a major version, but they're the exact same version. Um so anyway, in in v6, uh you know, using React 16.8, hooks are a really fundamental shift in the way that we think about writing React code, right? So, so there are a lot of things that we wanted to do in React Router, but at the same time, I didn't want to say like, well, React is completely different now, so React Router is also gonna be completely different. Too bad, right? Because now- because then we'd have people on v3, we'd have people on v5, and then we'd have only people who are building greenfield apps could use v6, right?

[00:24:08] Michael Chan: And to, I guess, to kind of like flesh out kind of the history that transpired in that time. Like, between v4 of React Router and 16.8 of React, the the the render prop slash like function as children or like whatever you want to call it had really kind of formalized into hooks.

[00:24:29] Michael Jackson: It's called render props, Michael.

[00:24:32] Michael Chan: I just want to make sure we get it. Talking about empathy, I want to make sure we get all the listeners on the same page regardless of what they call it. There's some weird-ass names out there for it.

[00:24:42] Michael Jackson: Yeah, no, no, absolutely. So, so render props, so render props, uh, uh, were, you know, kind of part of the inspiration for hooks. Um, uh, what happened was, uh, Ryan actually started using render props really, really heavily in this thing that he built called Component Component, which was basically a a um a component that used— uh it was a component API that used render props called, you know, like, didUpdate and willUpdate and didMount.

[00:25:17] Michael Chan: He basically turned the the class component inside out.

[00:25:19] Michael Jackson: Yeah, exactly.

[00:25:19] Michael Chan: So you pass everything in as props.

[00:25:21] Michael Jackson: Yep. Yep.

[00:25:22] Michael Chan: Yep. It still exists in Reach, I think. It's like component squared.

[00:25:25] Michael Jackson: Yeah, yeah, we're we're it's deprecated. We're getting rid of it. But but um there's like there's a there's a lifecycle component if you're interested as well in React Router v5 that is not external, but it's it's just something we use internally, um because the only way we had to get access to the router state was via render props. And so, but anyway, so the React core team saw this component-component thing and they were like, hey, that actually is kind of interesting, right? Like you have all these inline functions that you're using to sort of like close over stuff. Yeah. You can close over the state, you can close over the props, um and you can participate in the React lifecycle. Right. Which is exactly what useState does and useReducer and useEffect. Like, they're these inline closures over state and props and whatever else you want, um and that let you participate in the React lifecycle. So, um, so yeah, so so hooks are kind of like the evolution of this, you know, component component, which was an experiment that was done with render props. And so, yeah, so there was a— so so, you know, now that we have hooks, uh we- I I think they're transformative. I talk to a lot of people who are, you know, here we are like a year and a half after hooks were released and people are still like, yeah, you know, we just use the class-based APIs, we don't use the hook-based APIs. And I'm like, you missed it. Yeah. You missed it. Like, you missed something really, really transformative here. I mean, how, how else are you going to share the state of a component? How are you going to Uh, you know, compose that together with other pieces of state or augment that in a way that doesn't require you to create a new component or a higher-order component. Like, you you can't do that without hooks. Hooks are a lower-level thing that you need in order to do that. And needless to say, in the router, they're incredibly useful, right? We've got all kinds of state that we want to share with you as the developer. You can we want to tell you, here's the current you know, location, here's the current URL, here are the, you know, the parameters that came from the URL. Um, we want to let you hook into things that the router is doing, like that blocking thing we talked about earlier, you know. Um, and so-

[00:27:35] Michael Chan: So now you can get that data, the the state that you've stored, you can actually get that in your component at the right level through a hook.

[00:27:42] Michael Jackson: Yep. And you and you and you and you're not, you know, stuck in this like the render cycle anymore. Like you're You can do it in a hook. So, so anyway, um, you know, we we we okay, so React has changed. So what do we do? So we do we write a completely new React Router and then just leave everybody in the dust and say sorry? Um, so that was something that, another thing that I was, and and and it really, when I was getting, when I was kind of starting into React Router v6, like again, like late October last year, I I thought about this like so hard. I I I I thought about it for like 2 weeks and and Ryan and I had a bunch of discussions. We had like all sorts of like, well, if we did this, then we can tell people who are currently doing this to tweak their code so it looks like that. And then they can do a find and replace for all of those. And then it'll look like that. You know, and we thought about it like-

[00:28:36] Michael Chan: It's like a multi-step process.

[00:28:37] Michael Jackson: Yeah, but but like, and then we're like, nah, that's too hard. That's too hard. That just sucks. Like, let's, we gotta go back to the drawing board, you know? And so we were thinking about, you know, all of the existing code that's out there, all of the existing React Router code that's out there. How do we, how do we get, how do we move it forward? And so, what we've got in v6 is we actually have kind of two slightly different ways to use the router. One is the the component-based approach, the element-based approach, right? So, if you've used React Router or Reach Router, you're used to seeing like these elements that are stacked and nested that are that is essentially like your route configuration, right? And uh and we have that exact same uh usage style in React Router v6. Um we also have this like object-based routing config style. Um so previous to— uh or or you might some some people might be using this right now. We have this package called react-router-config in React Router v5. Um we are deprecating that in v6, and we're actually moving that into core. So anything that you could do with React Router Config, you can now do in React Router Core itself. And so uh so a RouteElement, you know, has a couple of props. A RouteElement in v6 has a path prop, an element prop. You could just, you know, and then and then of course routes have their children, their child routes or their nested routes. So you can just give us, you know, an array of objects with those same properties, with a path prop, with an element property. Cool. Uh with the children property that is another array of more objects like that. And you could you could just make your whole you know object config if if that's how you prefer to write things. And that is kind of how some people prefer to prefer to write things. Or maybe maybe they want to generate that object config from some data that they've got stored somewhere. Um you don't have to write it you know generate elements anymore. You could just generate these objects. And you could just put that route config into a hook that we have called useRoute. So what does useRoutes give you? Well, or what does it give you? You you put in all of your routes, you say use these routes, and you get back an element that you render. And so you you take that element, you say useRoutes, okay, this is the element that I'm supposed to render, and you render that element. And that element um is going to render the entire route tree all the way down.

[00:31:04] Michael Chan: Um so- That's a pretty wild use of uh of hooks. I mean, like We've we've we've seen examples of that, right? Where it like it returns an element as opposed to, you know, state or an object or like context or or some type of value. But um I think sometimes people forget that those can return anything. And so to return an element is like a pretty clever way to handle your use case. Thank you.

[00:31:29] Michael Jackson: Yeah, yeah, no, we thought so. So we've got we've got useRoutes and then we've also got another hook called useOutlet. Which also returns uh an element. But I I I I thought it was a really nice way to do it because— uh so I I I kind of obsess over APIs a little bit. And like I kind of like I'm always like chipping away at them. And I'll be like— and this is kind of one of the things that I think Ryan actually hates about me is he'll be like, look, this is great, right? And I'm like, well, I don't know, let's chip away at this a little bit more. Yeah. And he's always just like, daaah! But but I you know so we we actually went through a couple of iterations of this API. But then I was thinking, like, what do you what do you need from this route config? Right? You've got this big, massive route config. Why are you saying useRoutes in the first place? What do you need from that? You need something that you can render, right? We could have given you an object back with a bunch of data that tells you, like, oh, well, here's the stuff to render. And then you pipe it through another method to actually render the element. Mm-hmm. But really, you don't really need any of that. The only thing you need is, you know, I- here's a bunch of elements in this config. I just need to know how to render one of them, and they're already like nested appropriately. So then you just render that.

[00:32:39] Michael Chan: So these RouteElements, they kind of define an interface for how you're gonna interact with routes like across a React Router app, right? So you have the path, and then what were the other components of it?

[00:32:51] Michael Jackson: Yes, you've got the path, the element, and the children. Right now. Um, and then there are a couple- those are like the basic kind of bread and butter. So then you've got a couple of other properties. Um, one is the preload property, which is another prop that you can put on your route. So these- the the route elements themselves and these route objects are are analogous, right? They're the same thing. So the preload property is basically a function that we will call when that route is about to be rendered. And this is actually one of the really, really exciting features of React Router v6. Is we're we're finally— um and this is what I think a lot of the people who were on v3 who were using like the onEnter hook that we had in v3, uh I think this is what they were missing in v4 and 5. Is the ability to to to you know tap into the router's lifecycle so I know, okay, when this route renders, um you know, I need to run some code. And and so, what we've got is this preload property. And uh the preload property will give you the params, will give you the location. And then you can kick off your Relay query or your Apollo query, you know. Exactly. Or your React Query query. Um whatever data loading library you're using, you can just go and kick off your query there. Um and uh and then when React comes back around and and you actually, you know, you render your element, you can use whatever Suspense-compatible hook that those libraries provide. And they all use one. Yeah. Relays is called usePreloadedQuery. So you say, um, you know, in uh in the in the preload prop in your route, you would say preloadQuery. And then in your component, you would say usePreloadedQuery. And uh and that would actually grab the data uh from, from the query that you had in your preload prop. Uh one thing that's really, really nice about having it as a property of the route instead of on the elements themselves is that we don't actually have to load the elements, right? So you could be using, for example, React.lazy. Yeah. Because you're code splitting, um and you've got an element there that you ha- you haven't actually im- like loaded the code for that element yet, right? And so, uh so if you had the code located there with that element, you would you would basically have this waterfall if you code splitting, you'd have to load the element. Okay, now we kick off the query to load the data for that element. Um, and so putting the putting it on the route itself lets us uh just match the entire route tree.

[00:35:19] Michael Chan: Yep.

[00:35:19] Michael Jackson: And then we can say, okay, preload them all right now.

[00:35:22] Michael Chan: Yep.

[00:35:22] Michael Jackson: Um, and then if you're doing code splitting, uh, you know, React.lazy will do the waterfall thing like it normally does. Um, but you've already preloaded all of your queries. So as soon as those As soon as the code shows up, you're ready to render.

[00:35:36] Michael Chan: This is one of the the big challenges I think that we've we've seen in really understanding the power of Suspense is is that Suspense and all that it does depends on some level of routing.

[00:35:51] Michael Jackson: Mm-hmm.

[00:35:52] Michael Chan: In order to actually opt into these features and do the kind of like golden renders you fetch or whatever string of words. Is like the golden path that Relay's using. The kind of elephant in the room is that requires integration at the router level. And you know, whether you build it yourself, you know, like we've seen in the demos of Suspense, you know, all the all the ones that you can poke around with at— was it reactjs.org? The elephant in the room is that you're gonna have to have a router that can do all this, that knows about Suspense. And so that's that's a big take.

[00:36:24] Michael Jackson: It's huge. Yeah. So I was talking to Joe Savona a lot about this. He's um He works on the Relay team at Facebook. And, you know, he he he said, you know, Relay actually itself kind of started out as a routing framework. Yeah. But uh but then kind of just transformed into this data layer because they already had a lot of routing, I guess, at Facebook that they were, you know, using sort of their internal, uh you know, routing framework. And uh and so, you know, they they kind of said, okay, we're we're not gonna do the routing. We're just gonna give you these hooks, like, for the data. Um, but yeah, you're you're absolutely right. Like, in order to in order to complete the picture, like, sometimes I feel like at React Conf, Facebook gives you— and I'm this is not a diss on Facebook at all— but they give you their their slice of the pie. Yeah. Right? Let let me tell you about what I've been working on with React. Let me tell you what I've been working on with Relay. And then this is how it all sort of works together at Facebook, but you don't have that piece. You know, you don't have the router piece. And um-

[00:37:30] Michael Chan: Yeah, once you figure out the router thing, you're golden.

[00:37:32] Michael Jackson: Yeah, exactly. Once you figure out BigPipe, go go go crazy, right? And uh and that's the piece that that people, you know, who are trying to sort of stitch them all together, stitch together, you know, Suspense with data loading and React. Uh really need. So that's what we're bringing in React Router v6. It's basically the the missing piece.

[00:37:52] Michael Chan: Interesting. So so it's it's heavily leveraging uh hooks because obviously the the the render prop, it was kind of like a precursor to hooks. And so now you're just kind of like doubling down on that as an API, doubling down around elements, and now they have way more functionality. You can kind of nest them, you can like create these route configs and you're always gonna get these elements back through the hooks, kind of really closing the the gap between like V5 and V3. And um and it's all Suspense ready.

[00:38:24] Michael Jackson: Yeah. Yeah, yeah. So there are a couple of things to think about with Suspense. There's data loading, which is one of the things we've already talked about. Um the other thing to think about is, you know, navigation, right? Link clicks. Um let's say somebody clicks on a link, you start loading a route. And then, you know, maybe it takes a while or whatever, you're suspending, you're showing them a spinner, and they can still see the nav, and they're like, you know, that page is taking a while, I'm not, you know, and I actually meant to go to this other page. So they go and they click another link. Well, now what are you, now what are you gonna do? You know, where are you gonna be now? Um, and and and most importantly, remember that history stack that we were talking about? What does that look like? Mm-hmm. So if they clicked a link to A, uh, and then while that was still loading, now they clicked the link to B, Uh, do you want A to be in the history stack? Probably not, right? Because if they click the back- if B loads and they click the back button, they don't want to see a page that they never actually went to, right? Even though the URL already updated, right? So stuff like this that you have to think about, uh, when you're- when you're talking about loading like multiple different routes.

[00:39:27] Michael Chan: Because Suspense exists to kind of define that third state, right? Where it's like, you're not on this page, you're not on this page, Yeah, you're suspended. You're in limbo.

[00:39:36] Michael Jackson: Yep. Right? Yep. Yep. And so, um, so that's, uh, another thing that, uh, that we've got in React Router v6, which, um, which is, is basically just, you know, in that situation, we're going to do a replace. If you're- if, if we know that you're suspended, uh, we're gonna do a replace. And so that entry doesn't end up in the history stack.

[00:39:58] Michael Chan: Cool.

[00:39:58] Michael Jackson: Um, there are other Uh, there there there are a couple of other um suspense things that I that I would like to get in there before we hit final. Um, one is, and it's related to the to the preloading, um, but instead of like um uh preloading uh uh when a route is actually going to render, I want to let you do the initiate that preload sequence ahead of time.

[00:40:24] Michael Chan: Yeah.

[00:40:24] Michael Jackson: So, let's say, you know, your app is loaded, everything's great, and you're idle and the user's just browsing around, maybe maybe you know that they're going— that you know that they're probably gonna go to the uh the profile page or the dashboard or whatever, that's highly likely. Um we're gonna provide an imperative API that'll let you say, okay, you know, now that everything's loaded, go ahead and preload that other page as well. Yeah. Um and that will hook into the normal preload sequence, so you'll have all of the you know, the the parameters and everything that that you that you need uh to to do the data fetches that you need. And and having that kind of an API, one thing that's really nice about that um is we can enable you to— like we can we could even call that when you're like, um you know, like mousing over a link or like right when you click on a link or something like that, right?

[00:41:14] Michael Chan: And that's that's some of what Facebook demonstrated in in at React Conf.

[00:41:18] Michael Jackson: Totally. Totally. So bringing that to the router as well.

[00:41:21] Michael Chan: And so I I I think it's important to clarify for anyone who's listening to it like this month, like March 2020,

[00:41:28] Michael Jackson: yeah,

[00:41:28] Michael Chan: um that that React Suspense is all like speculative. It's like in that experimental branch. So you're you're as a library author like making road for it, but like anyone who's listening and not quite sure what the status of Suspense is right now, it's kind of like this isn't really something that is in applications. Yeah, absolutely. And ideally something that they wouldn't really need to even worry about if they're getting it through React Router.

[00:41:57] Michael Jackson: I think so, actually. I think so. Yeah. So there's been a lot of talk about Suspense, but I I honestly think that if you're using the right libraries, you as an application developer aren't gonna have to know too much about it. I think if if you're using, you know, for example, you know, a lot of web apps, you just, you need a router because you're just, you're gonna click a link, you're gonna show a new page and you want the data for that page so you can render the page, you know, once it shows up. And I think that's a large portion of the use cases for Suspense and and for like building web apps in general, you know. So, um, if you're using React Router v6, a lot of that'll just- Be done for you. I mean, that was like- I think that was actually the use case that Dan was, uh, was demonstrating when he first demoed Suspense like 2 years ago, right? It was like he was clicking on a thing and he was going to a page and they were loading some data so they could show the page, right? Like that was- that was it. Yeah. You know, and and I think, uh, I think if you're, if you're using React Router v6, obviously you're gonna have that. So, you know, and and well, like another library that we're working on is Reach UI, which we mentioned, um, kind of toward the beginning. And Reach UI is like, we need to, we need to think about Suspense there.

[00:43:16] Michael Chan: Yep.

[00:43:16] Michael Jackson: To like, for example, if you like click on a list box and you're gonna dynamically load the items in the list, maybe you'll have a spinner there or whatever. So, but, but again, that's gonna be built into the library. So as an end consumer, I don't think you need to worry too much about Suspense. Your API is gonna be You know, render a router, render your routes, and then uh throw a Suspense fallback around it anytime you need to render a fallback when something's still loading. And that's it. That's that's all you need to know.

[00:43:47] Michael Chan: Well, and I think that that's the vision, at least from what I've heard of the React core team around Suspense, is that there's a lot of hype because it's like new feature and and whatnot, and they've had to document it. But the intention has always been to like create these paths for library authors. You know, so like React Router, Reach UI, um Relay, Apollo in the future.

[00:44:08] Michael Jackson: Yeah, and and to Facebook's credit, I think they've they've they've been very clear at communicating that, you know, like the, you know, the uh Joe again, uh the post, he wrote a post uh like last October uh about it and he was like, you know, this is a post for library authors. Yeah, you know, and uh they've been they've been incredibly helpful at like giving us feedback and helping us to figure out like, okay, what's the best thing you know, what's the best way to adopt this. But yeah, to your to your earlier point, Suspense is still very much experimental. So React Router v6 is not going to have a hard dependency. Like we don't require that you're using the experimental branch of React. We detect it automatically. If you're using it, great, you get all that stuff. If not, like everything still works. It's fine.

[00:44:51] Michael Chan: Interesting. So you handle it progressively. Like, hey, we offer you an API. It works uh either just just in a hooks-based version or in you know, if you're using the experimental version that has Suspense in it, and it'll just kind of progressively handle all of that under the hood for you.

[00:45:07] Michael Jackson: Yeah, and once Suspense lands, it's uh it's gonna be nicer. Like it's actually going to suspend instead of instead of everything being synchronous.

[00:45:16] Michael Chan: Cool, cool. So you would get a lot of those behaviors like you talked about where it's just like it's already figuring out kind of like, oh, well, this like this view never resolved. So we're not gonna put that on the stack.

[00:45:27] Michael Jackson: Yeah, absolutely. Yep.

[00:45:28] Michael Chan: Nice, nice. Now I want to talk a little bit about- there's a couple new features. And I want to give you a chance to talk about those. But like ranked routing and then also like uh routing-

[00:45:40] Michael Jackson: Like nested?

[00:45:41] Michael Chan: Nested everything.

[00:45:43] Michael Jackson: Oh, relative. Yeah, yeah, yeah.

[00:45:44] Michael Chan: Relative everything.

[00:45:45] Michael Jackson: Yeah, yeah. So these so these two were uh kind of like the two main things that I wanted to get from Reach Router. And uh so so the idea of ranked routing is something that uh we've actually seen, like I think Ember does ranked routing. Um Jason Miller was doing ranked routing in his Preact Router. The idea and and and it was a big source of pain for people in React Router v4. Basically, React Router v4 has this switch component, which works like a switch statement, which as you know, just steps through the cases one by one, top to bottom. And uh and so, the first route that matches, going top to bottom, uh renders the renders the page. And it's it's fine, it's predictable. Um but uh but it's also, you know, there have also been some kind of gotchas there. So most people doing a React Router v4 or v5 app, they have a route with the path slash, and they haven't they have to put an exact prop on it. And uh this was something that that I felt was wrong with React Router like almost immediately after we released v4. Was because every every single web app you'd ever write would have a route path equals slash. Oh, and then we got to throw that exact prop on it. Because uh if the path is not exactly the slash, then we want to keep going and try and match other routes. And it's actually kind of funny. There was an issue that I opened like 3 years ago in the router where I was like, this feels wrong. And then- but I was like, I couldn't put my finger on why I felt it was wrong. But anyway-

[00:47:24] Michael Chan: But your gut was telling you. Yeah, yeah.

[00:47:27] Michael Jackson: Well, and there was- and like, I automatically- I, I, I closed the issue like 15 minutes later after talking to Ryan about it. I was like, yeah, it feels wrong. And then he's like, Bob, but how are you gonna do nested routes? And I'm like, oh yeah, I know, you're right, do nested routes. We can't do the nested routes, uh, unless we just match the beginning of the URL because Like if if if every path matched exactly, then uh then you would never ever ever get to render any of the nested routes because the parent route would consume the entire URL. Yeah. So we were like, so I was like, ah, okay, fine. And so I closed it. But then I thought again, I was like, no, but there's this dumb exact, like there's something wrong here, you know, like there's something wrong and I don't know what it is. I don't know how to fix it. And so, um, so that issue just stayed open for like a couple of years while we like talked about it and like tossed it around. Um, so anyway, v6, we are fixing this big time. So we're doing- we're taking this ranked routing approach, which basically works, um, kind of, kind of like CSS, kind of like the- kind of like specificity. Okay. Right? So how specific is this route? You know, how, how many segments are there? How do you have static segments? You know, and based on the based on the the the type of the path and the number of things that you have in the path, we can tell how specific it is. And so we can rank them and say, uh you know, this this route is more specific than the rest. So when we're going and we're matching, instead of just going top to bottom, we're gonna we're gonna try to match this one first. And if we can, well, then we're gonna take that one. Um and it requires You know, it requires a little more trust on the part of the developer to trust that we got our ranking algorithm right and all that. Um, we've got tons and tons of tests on it. And if there's ever a, a, you know, bug in it or whatever, we can just figure it out and we can, we can add another test for it. But the idea is that you should never ever have to actually think about it. You should be able to just write out your routes and it'll, it'll, the router will automatically do the right thing. This is really, really cool for uh something else that we're working on, which is um file system-based routing. So think about, you know, like à la Next.js, right? So think about like laying out your routes, you know, in files. Um, you, you know, the the the the file system just sorts them alphabetically, right? Um you don't- you can't order them at all. But if you have a router that automatically knows how to rank routes, it doesn't really matter, right? You can just read in the whole file system, the router, and you can just shove them into the router, and the router is gonna automatically uh rank them for you. So uh it's it's gonna unlock some really, really cool stuff for the future of React Router. So-

[00:50:21] Michael Chan: That's awesome. Yeah, I mean, because that's one of my- objectively my favorite feature if I had to pick one of Next-

[00:50:27] Michael Jackson: Totally.

[00:50:28] Michael Chan: —is the file-based routing. Totally.

[00:50:30] Michael Jackson: We all we all love it from like our PHP days of building apps, right?

[00:50:34] Michael Chan: Like it makes me feel like a kid again.

[00:50:37] Michael Jackson: Yeah.

[00:50:37] Michael Chan: Writing writing PHP. Totally.

[00:50:39] Michael Jackson: Totally. Oh, I love it. I totally love it. I totally love it. So this ranked routing thing, on the surface, it might seem kind of like, yeah, like we're fixing some bugs, definitely, but we're also gonna unlock some really cool stuff.

[00:50:49] Michael Chan: Awesome. So you'd be able to get that. So So, so, I mean, not not to say anything against Next because there's so many other features that they they do are great. Um, but basically my favorite feature is something that I will eventually, uh, on the horizon, just be able to use in in React Router.

[00:51:08] Michael Jackson: Yeah, you're gonna get that out of the box.

[00:51:10] Michael Chan: That's awesome. So, so this sounds so- I'm trying to kind of like- so, so there's kind of that CSS analogy, but it sounds a lot to me like Almost like pattern matching for anyone who's used a language. A little bit, yeah. Pattern matching.

[00:51:23] Michael Jackson: A little bit.

[00:51:23] Michael Chan: Like more specific. You can kind of be as specific as you need to be to say like this is exactly the type- these are the constraints I'm looking for to match this case. Mm-hmm.

[00:51:34] Michael Jackson: Mm-hmm. Yeah, exactly. So and and so the path is just one way for you to actually match the current URL. We're actually adding um a method that is going to let you match Uh, the the types of the parameters and the things that you've got in location state. So you could actually have two routes at the exact same URL that match different kinds of location states. Let me give you an example. Um, so one route could be, you know, like a modal route. So you could say, um, you know, if if like like Twitter shows a modal if you're on the Twitter website, right, and you click on a on a link. to somebody's tweet, um, it's gonna they're gonna show that tweet, or uh you know, or they're gonna show that conversation in a modal above the existing page that you're on. So if you notice, the the URL um doesn't actually— uh or sorry, the URL changes to that the the URL of the tweet that you clicked on, and yet the page that you were on is still in the background. Now, if you refresh the page, or you like copy and paste that URL to like a different you know, I think actually if you refresh, I think you'll actually just stay there. But if you copy the URL and like into a new browser window, you're actually- you don't have that context, right? You lose the context because you're not at that page anymore. So again, same URL, two different representations of that, of that page. Um, you're gonna be able to do that kind of stuff that's really kind of subtle but really awesome stuff. Uh, you're gonna be able to do that a little more. I mean, you can currently do that in React Router, but you're gonna be able to do it a little more easily.

[00:53:06] Michael Chan: Yeah, and this is something that I think a lot of people don't realize how complicated it is. Yeah, right, it's details. If you look at, you know, Facebook or Instagram or whatever, they all have that kind of this way of, you know, if you're, if you're really looking for it, you'll see like, oh yeah, I open this up and it opens up a modal, right? But if I copy that link and paste it somewhere else, like actually see like a- I mean, to use Rails language, like a show page for that, right? Like it's a full page, not modalized, about that content. Same thing with like tweets on Twitter, right? You copy the URL, you go there, and it's no longer like that showcased over other stuff. Or I don't know, maybe it is.

[00:53:43] Michael Jackson: Yeah, no, absolutely.

[00:53:45] Michael Chan: They go back and forth at Twitter.

[00:53:46] Michael Jackson: They do. So yeah, that's that's uh one of the main features that we are really excited about is um kind of the ranked routing and these like enhanced ability to match URLs. Um the other main thing that we cribbed from uh Reach Router was the relative everything, which honestly we should have had since day one, but we just weren't quite sure the best way to do it.

[00:54:11] Michael Chan: Yeah.

[00:54:12] Michael Jackson: Um, so we're taking this really kind of interesting approach. I think is very interesting because it, it kind of changes a little bit the way the web works, which is again might make some people a little uncomfortable. But we've been working with the router long enough now, I think, to be able to say definitively that that you I I think you're gonna really like this. Um, it is it so it works more the way like the command line works, right? So let's say that you've got a link, you know, that uh you know in in a web app, you could link, you could have like a relative link. And depending on what the current URL is, If it ends with a slash or not, that link goes to two different places. Um, so relative links on the web are are non-deterministic uh based on and on on whether or not the current URL ends with a slash. And and this happens— this this is actually, you know, a really common thing that people are doing with single page apps these days is like, they're, you know, they'll render the exact same page with or without the slash.

[00:55:19] Michael Chan: Yeah.

[00:55:19] Michael Jackson: Right? And and you know, people who do SEO say like, oh, you should redirect to one or the other, otherwise you're splitting your traffic between two different URLs, whatever. But it's it's a really common thing. You show the exact same thing, uh except your links would point to point to two different places if they were relative, unless you built them all the way from the root of the URL, right? Um so one thing that we're doing in React Router is we are ignoring the trailing slash.

[00:55:42] Michael Chan: Okay.

[00:55:43] Michael Jackson: Now, what does that mean? Does that mean you cannot have the trailing slash? Absolutely not. If you have a website where you want the trailing slash on your URLs, you want to link to a trailing slash, that's totally fine. Go nuts. It's just when we are matching, uh we do not let you render two different things at a page with a slash versus without a slash on the client side.

[00:56:06] Michael Chan: So you're making that decision. Yes. Because it is possible to render two different things. It is. Like slash, no slash, same content.

[00:56:13] Michael Jackson: Yes. On the client side.

[00:56:15] Michael Chan: Okay.

[00:56:16] Michael Jackson: If you were building that app on the server like I did for Unpackage, right? So like I have this, I have this thing on Unpackage where I, if you put a trailing slash, you see an index file of the stuff, right? Um, so I do that.

[00:56:29] Michael Chan: You're the problem.

[00:56:30] Michael Jackson: Yeah, I am the problem. Well, which is why I'm, I feel like I'm uniquely like positioned to be like, to speak to these people who are concerned about this, right? Because I've done this, right?

[00:56:40] Michael Chan: Yeah. Intentionally.

[00:56:41] Michael Jackson: Yeah, oh, intentionally, totally. Um, you can still do it on the server side, you just can't do it client side, right? When this- when the request comes into the server, you can say, oh, it ends with a trailing slash, I'm gonna show a different page than if it didn't, right? And you can match that with your Express router, your NGINX router, whatever you want. Um, it's, it's literally just on the client. The reason we're doing that is for these relative links, okay? So a relative link now- so, so, so basically what it means is when we, when we Uh, when we are generating the hrefs for your links, we ignore the trailing slash on the current URL. So what does that mean? That means that these links, these link to values, they work exactly the same as cd on the command line. Okay. So, so instead of- so on the web, you can be at two different types of things. You can be in a file or you can be in a directory. On the command line, you can only ever be in a directory.

[00:57:34] Michael Chan: Right.

[00:57:34] Michael Jackson: Right. On the command line. So, so when you say cd dot dot, there's no question you're going to the parent directory, right? On the web, when you say anchor tag href equals dot dot, well, it depends. Does the URL have a trailing slash or not, right? We're getting rid of that ambiguity. We're saying no, that's stupid. What we're, what we're saying is, um, you're always in a directory on the web, okay? We're always gonna, we're always gonna ignore that trailing slash. Like, if it's there, great. Fine, we're just gonna ignore it when we're generating this href thing.

[00:58:05] Michael Chan: Yeah.

[00:58:06] Michael Jackson: Um, which is- it turns out it was kind of the key for making these relative links intuitive. So now relative links work exactly the same way as cd works on the command line. Um, and there's- there's really nothing that you can't do. And I was very like hesitant about this particular one. Like this was one where Ryan had to like kind of goad me a little bit. I was like, no, we can't change the way the links work. That's crazy. That's crazy talk. I've I've done the work. There is nothing that you cannot do. The only thing that you cannot do is you cannot render two completely different things with a client-side router, with a slash and without a slash. And if you're doing that anyway, uh, you're you're you're a bad person. So.

[00:58:51] Michael Chan: So it sounds like with this notion that you have of kind of like cd being being relative, like as as in the terminal, that you can kind of organize your application into like maybe like smaller applications with like smaller routers and like smaller everything and kind of have a notion of like, this is this thing and kind of have maybe a smaller worldview, I guess, instead of like what we've seen where you have like these just kind of like big, massive routers. I mean, I've worked in Rails for years and And sometimes the route files are like hundreds, thousands of lines long. And it would be nice to, to be able to pare that down a little bit and say like, well, this is actually only these little things. And like, I think they've done that a lot with DSL and kind of like making the language more terse, but it sounds like in with React Router, you're gonna be able to do that kind of in a more, like actually closer to the code.

[00:59:45] Michael Jackson: Yeah, no, absolutely. I would, I would say that's definitely true. The, uh. People ask me sometimes, they say, like, well, like, how do I build a large React app? And my answer is always, you don't. Like, you you just build lots of tiny apps and you stitch them together, right? That's one of the cool things about the model, the the component model, the element model, is you compose them together. And uh so the router, I think, with this notion of everything being relative, both routes and links, lets you compose apps together.

[01:00:17] Michael Chan: Yeah.

[01:00:17] Michael Jackson: Which themselves are obviously composed of elements, but the, you know, being able to compose at the application level means that you can say, for example, here's, you know, in a large organization, here's a team that works on this feature of the app. Maybe they work on the chat feature, and then this other team works on the main feed, and this other team works on the dashboard, and they all have their own routes that are kind of specific to that feature, um they're not all working on and committing to the same route configuration. You know, they're just committing to their own separate little route configs, and then uh when it comes time to stitch them all together, it's a lot easier to do that since everything is relative to the root.

[01:01:00] Michael Chan: This might be the wrong question, but would that maybe be a path forward for people who can't maybe migrate their entire app to the latest React Router, but you know, if they're starting a new section of their app, want to like, you know, start it on the like latest and greatest?

[01:01:17] Michael Jackson: You know, I wish that were true for, you know, people going from v5 to v6, but right now it's not. We're we're currently working on making that migration path smoother. Um, there are just some things about how v6 works differently under the hood internally That uh that make that difficult. But there's, you know, one thing I've one idea that I've been toying around with is maybe, you know, this idea of like, um, you know, shipping like a v5-compatible switch in React Router v6, right? And if you use one of those, then you go into like v5 mode. And um, and that, you know, that might allow some level of compatibility with v5, but then we'd have to be able to capture a bunch of the other nuance with v5, which is, you know, it's how far do you want to go down that rabbit hole, you know.

[01:02:13] Michael Chan: You're gonna have to draw a line somewhere.

[01:02:15] Michael Jackson: Yeah, exactly, exactly. So right now, um, we've, we've, you know, our migration guide is pretty thorough. It tells, you know, describes like, okay, here are the steps that you need, uh, to get onto v6. Um, but there is kind of a- there's a jump at that point where you go from the switch to the new routes and relative routes and all of that relative stuff starts working. So, um, hopefully in the in the future, now that we— I do feel like we've really nailed this relative thing, relative links and routes, um, we would— we will be able to provide a little bit more, um, easier upgrade path in that in that situation. Yeah.

[01:02:54] Michael Chan: Yeah, that brings up an interesting point and something that I really enjoyed about the way that you've been kind of rolling this out is, is that, you know, v6 is going to be kind of the hooks-based React Router. Like you're, you're, you're building against that, that, uh, construct. Um, but you've been including it as kind of like an add-on for like the last few versions of React v5 as like the ability to like kind of like start implementing hooks, but still on v5.

[01:03:24] Michael Jackson: Yeah. Yeah, absolutely. So back, oh geez, seems like last summer, end of last summer, we shipped Uh, React Router 5.1, which included a bunch of hooks. Um, but since React Router 5 is backwards compatible with, you know, React 15, um, we said, okay, you know, you can only use the hooks, obviously, if you have a hooks version of React, which is 16.8. So we were we were kind of in this weird spot where we said, okay, well, you know, you can use the hooks, but only if you're on the right version of React, even though our dependencies of React is a lot, you know, includes versions of React that don't include hooks. Um, how did that relate to your original question?

[01:04:06] Michael Chan: Oh, I was just- I guess it was more of a compliment because I was just saying I really like the way that you're rolling it out where it's like you have this, um, and I think it's a lot like kind of React itself. It's like we have this vision of the future and we want to get there. Like we're adding things in a way that's like API compatible now, right? Um, even though the next version of it, it's that's just gonna be the worldview.

[01:04:27] Michael Jackson: Right. Well, yeah, no, thank you. So yeah, so so the whole uh the whole point of us shipping hooks in 5.1 was like, eventually this is gonna be the whole— like the whole— like you'll really, really want to use these. Um, in fact, we have this um one other just little API detail, and then I promise I'll stop talking about React Router API. But um one other API detail in React Router v6 Um, is that we, you know, in in in version 4 and 5, we had 3 different rendering APIs basically for the route. We had the render prop, which was literally called render. Then we had the children prop. Um, and then we had the component prop. And, um, you know, the component prop was kind of left over from like, that was our very original API.

[01:05:18] Michael Chan: That's where you have like a component, like a capital C, like define component, and you just pass that in. No angle brackets, just pass it in as a prop.

[01:05:26] Michael Jackson: Exactly. And then the render prop and the children- well, people are familiar with the children prop. Um, but then the render prop was a a function. And so we would give you like the current match state and the parameters, and then you would go and render something with it. Um, and so we had all these different APIs. And uh I I wrote a blog post about this. If you go and read the uh the blog post, we'll include this in the show notes as well, the the blog post for React Router 5.1. Um basically, they're they're all kind of superfluous in a world where you have hooks. Yeah. Right? Because if you have hooks, then you can really just give us an element and uh any of the router's internal state that you need to access in inside that element. So say, for example, you give us your Your homepage element, you know, the element that you use to render your homepage. Um, if you need any of the router state, if you need the parameters or the or the location or the location state, you can just use a hook inside that element and and grab that stuff. You know, there's no reason why we have to- so the component prop, the advantage of that was we could render it for you and we could pass you the props. You know, same thing with the render prop. We're passing you the, you know, the router's internal state inside this callback. Um, but but when in a world with hooks, you can just give us the element, pass whatever props you'd like, and then if you want to access the router state, just use a hook. So, um, so one thing we did in 5.1 is we really, really encourage people to just use the route children API. Just just use regular elements. Mm-hmm. Because when you convert to v6, um, you're gonna use the route element API. And so you can just move those elements from the children position into the element prop.

[01:07:03] Michael Chan: I like this idea, and I I know that Ryan's talked about it a lot, but this idea of um pulling versus pushing. And it seems like that's kind of like what you're able to get at with hooks and the React Router is is that you just give us an element, and when you're interested in opting into the uh the router state, you can pull that information from anywhere. Like

[01:07:25] Michael Jackson: yeah, exactly. We're not giving you a bunch of information that you may not even be interested in, right? Like, you- hooks really allow you to just sort of opt in and say, hey, I'm interested in this. I want to- I, I literally want to use this piece of state or this, you know, thing from the router. So there, there have been, uh, a few attempts from people, like, like, as soon as, as soon as I shipped the, um, the hooks version of React Router 5.1, there were some people online who were like, oh, well, You know, we really miss the withRouter thing, so let's just combine a bunch of the hooks that they're giving us now and useParams and useLocation and useHistory, and we'll just use all of those hooks and we'll remake withRouter. And I'm like, well, that's kind of like- like you're like, you kind of just like put yourself back in that original position, right? In in this, um, in the- you you kind of just put yourself back into the push boat. But now you're now you're saying, well, let's gather all of the data and let's push it all on them when really, you know, if that component doesn't need to navigate, you don't need the history API. If that component doesn't need to— uh I mean I mean you might not need any of those APIs.

[01:08:36] Michael Chan: Yeah. Well, and it's nice because I know that that that you've always wanted to get out of the way, right? And React Router, I think, has even been special among routers to bring to to to make the router just components, right? And like there's always been this idea of like, well, React is about components. Like let's let's make everything a component. And in that way, you're kind of getting out of the way of React, right? And you're saying like, hey, just make more components. Yeah. And it feels like now with hooks, you're honestly able to say like, you can use this with any component. It doesn't have to be special in any way. You don't have to render a route component. Like you just render a component.

[01:09:13] Michael Jackson: Yeah, yeah, yeah. So here's actually a little, uh, here's a little tip for React Podcast listeners. There is a, uh, so we talked about there are 2 router APIs. There are actually 3. There's, um, there's a secret menu API that we're not really talking about a whole lot, but, um, it is akin to the reach router API where you just pass your elements, like you don't even need the route elements. So if you, if you go looking through the source, you'll find it. Um, the, the route-

[01:09:49] Michael Chan: We love going source spelunking.

[01:09:50] Michael Jackson: Oh yeah, yeah, the route component. Go, just go and take a look at the source of the route component in React Router v6 and you'll understand exactly what I mean. Um, there, there are actually some tests that test the, uh, the secret menu API, so Go and give that- go and give that a look and and let me know if you like that.

[01:10:09] Michael Chan: It's awesome. We actually, um, when I had uh Swyx on, we we had a whole episode where we just talked about suspense, you know, suspense. Um, and it was all just stuff that we found in the source. Like it was all just out there, right? And just not documented.

[01:10:24] Michael Jackson: Yeah, yeah, yeah, yeah, yeah. In fact, uh, the the the the main reason that we are not recommending this secret menu as like our main API is because of TypeScript and the prevalence of TypeScript. Um, because it's hard to type, but if you're a JavaScripter and you don't care about types, um, it's actually nice and concise.

[01:10:49] Michael Chan: So that's the that's the perfect segue to like my next question, which was, yeah, as TypeScript has grown in adoption and interest and yeah, seems, at least from my perspective, to have kind of beat out Flow.

[01:11:04] Michael Jackson: Oh, for sure.

[01:11:05] Michael Chan: How is that impacting you as a library developer? As you, you know, React Router has been kind of here as long as we've really had React. And, you know, it's it's been a few years and you're coming out with a new major version. Are you doing it in TypeScript? How are you kind of like appeasing the new landscape of library consumers.

[01:11:25] Michael Jackson: Yeah, for sure. So, um, so for a long time people have said like, oh, we want some official React types- or sorry, we want official TypeScript types for React Router. And we said, um, you can go and get them from DefinitelyTyped, which I think has done a great job. Like, there's a very vibrant community over there. A lot of people, um, get their types from DefinitelyTyped. But, you know, TypeScript really has become big enough now that it, it really- we should just be publishing our own types. Yeah. My one hesitancy with that was I was like, you know, I'm not a big TypeScript user, so if I am gonna publish TypeScript types, what if I make a mistake, you know? Um, and that was where I kind of, you know, so that was why I kind of wasn't doing them myself. Um, and then it hit me, if my types are wrong that I publish, somebody's gonna make a PR and they're gonna fix them. And they'll tell me like, hey, your types are busted here, you need to fix it like this, and then we'll have a discussion about it. Um, so, so that's the, the plan basically in React Router v6 and History v5. Yeah. Is we're gonna publish full TypeScript types and you're gonna have the docs and the links and everything that you would expect from a full, uh, you know, from a good set of TypeScript types. And we're gonna publish them all in-house and you're not gonna have to use the you know, @types/react-router or whatever package.

[01:12:48] Michael Chan: It seems like a really interesting compromise because one of the challenges in converting a library to TypeScript is that you end up keeping out a lot of people who are JavaScript developers that might have been able to otherwise contribute to that.

[01:13:04] Michael Jackson: Yeah, I think it it it definitely— every everybody who can write TypeScript can write JavaScript. But the inverse is not true.

[01:13:12] Michael Chan: Sure.

[01:13:12] Michael Jackson: You know, and and people get very, very passionate about their tools. There are people who like swear by TypeScript. They will never write a a line of regular JavaScript as long as they live. You know, it's it's all about the TypeScript. And I'm just not- I just don't care that much about TypeScript. Like I it's a it's a tool that some people find useful.

[01:13:33] Michael Chan: Yeah.

[01:13:33] Michael Jackson: And so let's support them and let's provide A+ support, let's give them some great types. Um, if someday they want to come and they want to contribute to the React Router codebase, um, they're gonna crack open the, you know, the source folder and they're they might be upset to not see that we've got types. But I think it'll probably take them about 3 seconds before they realize, hey, this is just JavaScript and it doesn't feel that bad. Like it's fine, you know. Um, also, when they're working in the codebase, If they've got VS Code and they've got their editor up, like they'll have types for all of the function signatures and things that we that we export. Um and we've got excellent test coverage over everything. So um hopefully it won't be too painful for somebody who only knows TypeScript or who has like converted to TypeScript to uh to work in a JavaScript codebase again. But um honestly, the the vast majority of the of the React Router code is written by by me and and and other, you know, people who are totally comfortable with writing regular JavaScript. So yeah, it'll be fine.

[01:14:38] Michael Chan: Well, I find it- I find TypeScript to be really fascinating because I think that it does have a a virtuous cycle. Because I mean, I have a couple of super tiny libraries, like minuscule libraries, but even those, you know, people who have used them with TypeScript They have- they end up typing it anyway, just so they have some like security. And so many times they'll like send a PR in and like, hey, you don't have to merge this, but like these are the types for your thing if you want them.

[01:15:05] Michael Jackson: Exactly.

[01:15:06] Michael Chan: And it's great. Like, I love that.

[01:15:08] Michael Jackson: Exactly. Yeah. Well, and that's, and that's essentially what's happened on DefinitelyTyped is like people needed the types and so they went and made the types. I think, um, I've done enough TypeScript to know There are good types and there are bad types. Um, and so what I- one of my goals with bringing the types in-house, so to so to speak, is to make sure that we have like really, really great types. Um, there are there are something, you know, like there are types on DefinitelyTyped for like our internal-only APIs, you know, and things that just like don't need to be typed, you know. There are types for like higher level concepts that are really just like strings or Booleans and stuff like that. And so there are, there are some types that I think are superfluous or otherwise just not really needed. And so we're gonna prune those out in our own types.

[01:16:00] Michael Chan: Yeah, we saw that, I think, maybe a year or two ago in React itself, where a lot of the language was kind of being defined by the types that were on DefinitelyTyped. Yeah, right. Like, so there was that idea of like a stateless functional component, which was like, you know, in the docs at one point. Yeah. But then that got formalized as like a type.

[01:16:20] Michael Jackson: Yeah.

[01:16:20] Michael Chan: And then a lot of people were like, well, like, why is the language around this thing changing? And yeah, React team was like, why do you care? And you're like, well, this is how they're defined. Well, because-

[01:16:29] Michael Jackson: yeah, exactly, exactly. And, and, and I think that's- I think that's sort of backwards, right? Like, the library gets to define their interface and what things are called, and then the types are are, uh, I mean, unless the library itself is written in TypeScript, in that, in which case they're one and the same. Yeah. But if it's not, and the library is written in JavaScript, or in the case of React, it's written in Flow, then the types are really just sort of an appendage. And they describe, and they're great documentation, and they give you the IntelliSense and all that great stuff that you're used to, um, but the source itself is not TypeScript. So it, it should be, you know, the types should just, just describe what the source is doing instead of the other way around.

[01:17:10] Michael Chan: Yeah, yeah, yeah, cool. Now you'd mentioned, um, that you're doing a lot of stuff with the, with the build and kind of changing how you build React Router. Tell me a little bit about that.

[01:17:21] Michael Jackson: Yeah, I'm really excited about it personally. Um, so I've been getting some help from, um, from a couple of different people. Uh, Christopher Baxter is my shout out to him. He's been helping me out with, uh, using Google Closure Compiler So around probably about 6 months ago when I was just getting into like the rewriting everything, um, history and React Router, I, uh, I was kind of tweeting about it. I was like, gosh, you know, all my career I've looked at Google Closure Compiler. My entire career I've looked at it and I've been like, there is some, there is some sweet, sweet tech there.

[01:17:56] Michael Chan: Oh yeah.

[01:17:57] Michael Jackson: Underneath this unusable Just completely- I mean, it's just like obtusely difficult interface. Like, like, like, if you've ever tried to use Google Closure Compiler, it's in- it's incredibly difficult to use. You have to- like, speaking of types, like, it, it, it, you need to- I mean, if, if you want to use it like in really advanced mode. So simple mode, like, it can do lots of simple stuff by it, by itself, but where it really gets cool is when you can start taking advantage of of the advanced mode. And um and it's just really, really difficult to use, especially when when you're talking about things like JavaScript modules and advanced features of JavaScript. So anyway, um so uh oh and and and the other so so one of my goals was everything that we do, because React Training is kind of morphing into a software company, so like everything that we do, we're gonna run through Google Closure Compiler.

[01:18:52] Michael Chan: Just draw your line in the sand.

[01:18:53] Michael Jackson: Absolutely, yeah, absolutely. Everything we do, that's our compiler. We're gonna use that. And um and so I I you know thought, okay, it's time to figure out how to use this thing. And and I noticed that Christopher Baxter, um he's works on the AMP project at Google. They're doing a lot of really cool stuff there. Um he uh he had made this plug plugin for Rollup and Closure Compiler. So Rollup we were already using for our build. They're using Rollup for building lots of stuff in AMP as well. It's an open source project. And so he had built it for them. And so um so I I implemented it on both History and on React Router. And now we run all of our builds through Closure Compiler. And the the cool thing about it is it's it it's by far the most advanced JavaScript compiler out there today. Like you think, I mean, most people are using like Uglify or or Turser, which are really just minifiers.

[01:19:49] Michael Chan: Sure.

[01:19:50] Michael Jackson: Google Closure Compiler will actually like rewrite portions of your code so that it runs as quickly as it possibly can at at build time. So so for example, you might have a a loop that it would you know flatten out and eliminate some of the recursion, or you might have a couple of nested function calls that it reduces to really just one function call. You might have like a a constant that's defined outside of the scope of your function and you use it inside the function and Google Closure Compiler says, you know what, that lookup is more expensive than just inlining it, so I'm just gonna inline that for you. Um and you're not referencing it anywhere else, so it's not gonna break anything, right? So it can make really advanced inferences about your code and do things. So I I I really consider it a code authoring tool. Mm-hmm. And an indispensable part of part of our workflow. And so we're using that um with Rollup. And then um Rollup is another, you know, hats off to to Rich Harris uh and other uh several other people who've been contributing on that project. But it is absolutely another indispensable tool. Um and I want everything else that we do to be built using Rollup. So Rollup and Closure Compiler, because um so we've got a lot of different builds of the router. We've got, uh, you know, obviously a regular JavaScript modules build for anybody who's using JavaScript modules. Um, but then we also have uh pre-built development and production JavaScript modules builds for people who are using script type module. Um, and that's using Jason Miller's awesome Babel preset modules. Um, so typically this thing that Babel does uh when you're compiling using preset-env is it'll compile all of your JavaScript down to ES5 before it does any other transformations on the code. And what that means is you end up, you know, losing some of the really cool things that you can do in in modern versions of JavaScript, things like destructuring, right? Um and so uh so what Jason Miller did was he made this thing called preset modules, which basically means you don't you're not compiling all the way down to ES5 anymore. You're just going to compile the various things that the browsers that the that the modern browsers need, you know, for the the quirks for the different modern browsers. Um and it really does save you quite a few bytes. And if you're serving, you know, say you're loading scripts from Unpackage or something, you're using script type equals module, you know, every byte counts.

[01:22:20] Michael Chan: Yep.

[01:22:20] Michael Jackson: So we build so we we have builds for those uh as well, for script type equals module. We have builds for um UMD, obviously. So if you're still using CommonJS or, you know, some early version of Webpack or whatever, you're gonna get those. And then we have a a Node entry point uh that will just serve up one of the UMD builds in case you're in Node. So we have quite a few builds of all of the different libraries. So so there's three packages. There's react-router, react-router-dom, react-router-native, plus the history package. So we have lots of builds. Of lots of libraries. And the thing that I love about Rollup is I can just plug in all of those builds at one time, and I can say either build them all.

[01:23:00] Michael Chan: Yeah.

[01:23:01] Michael Jackson: Or I can say just go and watch them, you know, because I'm going and I'm running some tests. So I can say go and watch them, and, and only- it's only gonna recompile the builds that need it as I make changes to the file system. Um, so that's a really, really powerful tool that we've been leveraging a ton in both the History and React Router projects, but it's the, the, I've, I've, you know, sometimes people will say like, oh, like, why don't you just use some like build, you know, like if you're using TypeScript, like, like Jared, I love you, but he's like, just use tsdx. And I'm like, I can't use that, dude. Like I can't, I can't, I can't have somebody else saying like, oh, just let me own your build.

[01:23:41] Michael Chan: Yeah. Yeah. Yeah.

[01:23:42] Michael Jackson: Uh, not, not at this level, right? Like if I'm just publishing like whatever and I just want to get something done quick, like I can use somebody, you know, MicroBundle or somebody else's like bundling tool.

[01:23:52] Michael Chan: Yeah.

[01:23:53] Michael Jackson: But, um, but I, I want to make something like- I want to know everything about the build, you know? I don't want you to try and conceal it and hide it from me.

[01:24:01] Michael Chan: Yeah. Yeah. Well, and, and those tools are amazing. Like- Oh, for sure. Like MicroBundle is a such an incredible piece of technology. And same with tsdx, right, for TypeScript. And it's so great if you, you know, if you want to throw up some, you know, just small module that- or even a big module, right? Yeah. That you just want to share with the world and you don't want to spend a month trying to figure out how to run bills for it.

[01:24:24] Michael Jackson: It takes time. It takes time. Let me tell you, it takes time to figure it all out. Yeah, it took- it took me like- that was December for me. That was like 2 weeks of that and then 2 weeks on vacation wondering why I had spent the last 2 weeks screwing around with my build when I could have been productive.

[01:24:40] Michael Chan: But it is true. Like like you said, at your at the level that you're creating and operating this library, you know, the question is like do you want to like do you want to just be able to fix the build and and adapt it to your needs or do you want to open up a pull request and hope that like Jared's in a good mood that day? Jared, you know I love you.

[01:24:59] Michael Jackson: You nailed it. No, you nailed it. Like I I just I want to know everything about the build. If something something's busted, I know exactly where to go to fix it, and I'm gonna fix it.

[01:25:06] Michael Chan: Yeah, because there's so many cases, you know, running a big project like this where we're starting with something like that, it could be great, right? Yeah. But at some point, uh, you're gonna run into that thing where you're gonna have to fork the project and make it your own anyway.

[01:25:19] Michael Jackson: Yeah, you know, we actually ditched Lerna as well. Like, I'm like, no, nothing is sacred. I'm like, okay, you know, so, so after- so once I got to that I'm like, okay, we we have our own build. Like I'm I'm using Jest, which is another amazing tool. So huge shout out to the Jest team. So we're using Jest to run our tests. We use Rollup to run our builds. And I was like, what what the heck am I even using Lerna for at this point? Like to publish? Like that could be a 30-line Node script, right? NPM publish this, NPM publish that, NPM publish that. And, uh, and so I wrote, I wrote a, a publish script and I wrote a version script, and that took me like an afternoon to write those two scripts. And now I never have to know anything about Lerna ever again. So like, but again-

[01:26:09] Michael Chan: Trade-offs, right? Because, you know, for you it is only like, you know, 30 lines that you were able to write. But for someone else, you know, like someone else needs the generalized tool because they're just like, I don't even know. I just

[01:26:21] Michael Jackson: know that

[01:26:21] Michael Chan: I need to publish all these packages and You

[01:26:23] Michael Jackson: know where I kind of took some inspiration from was uh from the React repo itself. So Brian Vaughn has actually done quite a bit of- he he last year he did quite a bit of work with uh building React itself. And I just kind of looked through it and, you know, they've got, I mean, they've got, they've got a lot more builds, first of all, than we have. Um they've got a lot of builds and, um and it takes a little bit longer to actually run their builds. But, um, you know, I I I I kind of, I spent a lot of time like sort of reading through the scripts that they've got and And it's, you know, it's very straightforward. And there's something that just feels really nice about just being able to open up a script and read it top to bottom and say, here's all the steps. And I mean, especially like scripting Node is really nice these days now that you've got async and await and everything. Like, you're speaking to somebody who like was been doing Node since like 0.4, right? Where it was like callback craziness. But like scripting Node is actually really, really easy. These days and it and it feels great. So yeah, I just, I wrote a couple of scripts. We use Jest, we use Rollup, we use Google Closure Compiler, and we use Babel. That's about it.

[01:27:29] Michael Chan: That's awesome. It's fun to kind of get a glimpse into kind of what that looks like for a mature project. And again, like not diminishing the, the importance of these general purpose tools for other libraries, but kind of as you advance, like the importance of kind of owning your own tool chain and kind of not being beholden to another library.

[01:27:50] Michael Jackson: Yeah, and again, you know, it's like, it's like you said earlier, it's trade-offs. When you- you can use that stuff too to get like some- get somewhere really quickly, and then you might find out, I'd rather own a little bit more of this, right? It's kind of like, uh, the same idea of eject in Create React App, right? It's like-

[01:28:06] Michael Chan: Oh, don't get me started on eject.

[01:28:09] Michael Jackson: Except with after you run eject, you look at it and you're like, what is

[01:28:15] Michael Chan: Eject me out of this plane without a parachute.

[01:28:17] Michael Jackson: Eject me out of this career, please. I will- yeah.

[01:28:25] Michael Chan: I might eat shit for that. Uh, cool. Well, this has been super illuminating. Um, is there anything else that, like, as we as we close this off, is there anything else you want to tell us about?

[01:28:36] Michael Jackson: Um, just let me give you my sales pitch for React Training. Of course. Yeah, so reacttraining.com. Go and check it out. We've got public workshops coming up all the time. We've got some incredible instructors on our team. We've got Cassidy Williams, Brad Westphal, James Long, the the guy who wrote Prettier, David Khourshid, Mr. State Machine. We've got a lot of you know different amazing people helping us out doing uh workshops. And uh we've trained We've trained a lot of different teams. You know, I was, I mean, name name a name a tech company, we've been there. So if you've got any training needs and you wanna uh you know hook up, just go ahead and shoot us an email, hello@reacttraining.com. We'd be happy to talk to you about it. We're also always working on our online content. So for updates about that, you can go ahead and sign up for our newsletter and um hear news about our open source and other stuff we're working on.

[01:29:33] Michael Chan: I love it. And where do people find you, Mr. Michael Jackson?

[01:29:36] Michael Jackson: Oh yeah, me. I'm just @mjackson on Twitter and GitHub. And anywhere that I couldn't get that username, you will not find an account for me.

[01:29:45] Michael Chan: Sorry, MJackson.

[01:29:48] Michael Jackson: That's right, dude. It was so sad. I went to Instagram and it was taken by— and I was like, well, I guess I'm not using Instagram.

[01:29:54] Michael Chan: Dude, I do the same thing. Well, platform's dead to me.

[01:29:57] Michael Jackson: Yeah, I guess. I guess so.

[01:30:00] Michael Chan: I guess I don't use Snapchat.

[01:30:01] Michael Jackson: Yeah, exactly, exactly.

[01:30:03] Michael Chan: TikTok? Nope.

[01:30:04] Michael Jackson: Well, an @mjackson is such a hard one to get, so- I got- oh, SoundCloud! I got my SoundCloud. Oh yeah. That's what I'm gonna be working on. My sound- I'm @mjackson on SoundCloud, check it out.

[01:30:15] Michael Chan: Awesome. Hey, thanks, Michael. Really appreciate it.

[01:30:18] Michael Jackson: Thanks, dude. Anytime.

[01:30:21] Michael Chan: This has been episode 85 of React Podcast. Divine links to the people and projects mentioned in this show, visit reactpodcast.com/85. If you like this show, there's a fast, free way to demonstrate your support. Leave us a review on iTunes. It's the best way for you to let me know what you think we're doing right and what we can improve. 2 to 3 minutes of your time helps us make the best show we possibly can. As always, links and show notes for all episodes are available at react This episode was edited by Mikael Delport. It was produced by Mikael Delport and Sarah Jackson at Spec, a network to help you level up in design and development. Check out spec.fm for other shows that are sure to fast-track your career. I'm your friend, Chantastic. Thanks for listening. We'll be in your ears again next week.