chantastic.fm

2: Razzle, After.js, and Formik with Jared Palmer

Episode 2 · February 20, 2018 · 00:35:43

Hosted by Michael Jackson · With Jared Palmer

Download MP3 · Jump to transcript

In this episode Michael Jackson talks with Jared Palmer about Razzle, After.js, Formik, several other open source libraries from Jared, as well as TypeScript and the implications of the upcoming async APIs in React.

Featuring

Links

Transcript

[00:00:06] Sponsor: This episode of the React Podcast is brought to you by ReactTraining.com. In-person, hands-on training for development teams from React community leaders and experts. Visit ReactTraining.com to learn more.

[00:00:20] Michael Jackson: Hello, everybody, and welcome back to the React Podcast. I am your host, Michael Jackson, and I have a very special guest with me today, Mr. Jared Palmer. Say hi, Jared.

[00:00:36] Jared Palmer: Hey, how's it going?

[00:00:37] Michael Jackson: So Jared, if you do not know who Jared is, you you've probably been kind of living under a rock. Jared has been doing a lot of cool stuff recently in the React community. Most recently, he released a library called After.js. He's done a library called Formic. And another one called Razzle, as well as lots of other stuff. So anyway, I just wanted to get started with Jared. By the way, he's he's in New York City. So if you're in New York City and you want a cool person to hang out with-

[00:01:06] Jared Palmer: Yeah, I'm around anytime.

[00:01:08] Michael Jackson: Oh, and you also do like a bunch of Reason stuff, right? You run the Reason meetup in New York.

[00:01:14] Jared Palmer: Yeah, trying to. It's it's been it's been you know it's hard to get speakers. Everybody's everybody's it's big in Europe. It's big in in in on the West Coast, but it's it's hard to find a consistent number of speakers, I'd have to say, for the Reason meetups. We're trying to do- we're trying to do another one soon.

[00:01:28] Michael Jackson: Yeah. The Reason uh community is- it's still very, very young. But, um, but if if if anywhere you could find a a meetup that that I think would work, it'd probably be New York, right? You could probably- lots of developers in New York, lots of talent.

[00:01:41] Jared Palmer: Yeah. The the one we did, the one we did last summer was very well attended. There were like uh 50, 60 people there. It's pretty cool.

[00:01:47] Michael Jackson: Well, hey, I'm I'm I'm getting ahead of myself. Um, I I just wanted to talk about a couple of these uh projects that you've been working on. So uh So let's start with Razzle, which I think is uh it's not directly related to React, but it is a you know I think it'll be really interesting to the people listening to the podcast because it is a a JavaScript library, right? It's for making universal JavaScript apps.

[00:02:14] Jared Palmer: Yeah, yeah. So Razzle was it's a build system, so it's basically a thin layer over Webpack. And what's cool about it is that it actually is, as you mentioned, completely framework agnostic. And what I mean by that is you can use it with anything you can use Webpack with. So, uh the the common thread there being JavaScript. But if you wanted to use it with Vue or you wanted to even work on some— uh even add like Elm to it, or if you wanted to do stuff with Reason, you can do that as well. Uh the default is React. Um and the the reason I sort of built it was I had uh I was like a really early adopter of a of a project called Next.js. And I probably like jumped on— and I was using it for a pretty big project. And there's just like a lot of churn. And now it's come— you know, it's it's miles ahead of where it was back even just that like a year and a half ago or so. And then I moved to this project called Kit by the New York Times, K-Y-T. And that's their like webpack setup for isomorphic universal apps for server-side rendering and and stuff. And that was cool, but it was still pretty opinionated and I wasn't really in control a project. But I liked this idea uh that um Kent Dodds and and Dan Abramov have been uh championing, which is like build a toolkit, don't build a boilerplate. And I had this like boilerplate actually that was pretty popular called like React uh Production Starter. I don't know why I decided to call it that, but it was it was pretty popular. Um and I was like, I need really need to upgrade this. And it seems like it's probably a good time to just to do that. And so, what I did was I uh I built a toolkit much like Create React App, actually, but with um server-side rendering kind of like ready to go. And by the time I was done, I was like, wait a minute, React's not actually what I've sort of— like this is not dependent on React at all. Um this could be used for a whole host of stuff.

[00:04:05] Michael Jackson: So, if uh if you're going to use uh Razzle, you're also gonna buy into Node.js on the backend. Is that right?

[00:04:12] Jared Palmer: Uh, well, not for like necessarily your API, but to the extent that you need it for server-side rendering, then yes. But I guess if you're doing server rendering in React, like you don't have many options except for using Node.

[00:04:21] Michael Jackson: Absolutely. Yep.

[00:04:22] Jared Palmer: I think there may be like one other, one or two other, like the PHP thing, but I haven't seen much use of that or heard many people using that.

[00:04:28] Michael Jackson: I built a little uh standalone thing. Uh, I don't know if I showed that to you. I called it React Standard IO.

[00:04:34] Jared Palmer: Oh yeah, I saw that.

[00:04:36] Michael Jackson: I've seen that. That's pretty cool. It's nothing like fancy. It really is just a little uh script that just, you point it to a component and then anyway, I was uh I was thinking about uh you know taking that a little bit further and wrapping that up into like a, you know, a library for PHP or uh you know uh an Elixir library or something. Actually, I had a-

[00:04:56] Jared Palmer: It would come in handy, to be honest. Like uh I was working on some some WordPress site and I really wanted to use a a navbar that I had written in React and I was like, uh be great if I could server render this.

[00:05:08] Michael Jackson: Yeah. I feel like the the two worlds are they're gonna converge at some point and it's gonna be beautiful when they do.

[00:05:14] Jared Palmer: Hopefully. Hopefully.

[00:05:16] Michael Jackson: So you were kind of scratching your own itch. Now, why don't you why don't you let us know, like, what what kind of stuff are you building? You work at the Palmer Group, right?

[00:05:23] Jared Palmer: Yes, yes, yes. So um

[00:05:25] Michael Jackson: what are you guys doing there?

[00:05:27] Jared Palmer: So we're building a lot of applications for um ourselves uh and also um our clients, which range from like big media companies to Fortune 500 companies to um trade associations uh at varying levels of sophistication uh with with respect to their engineering teams. And so um a recent project of mine that I've been working on for a while has been this um Pinterest-like UI for one of our best- that's the best way to describe it- for one of our for one of our clients. And that's needed this kind of of Razzle as a build system or sort of setup where- or I should say tooling, I guess, uh with um server-side rendering, uh and then also React Router 4, which is a big reason also why I didn't really- you talked about scratching the itch. One of the reasons why I really wanted to um build something uh that could leverage React Router 4 that uh with a server-side setup. So that's where Razzle kind of sort of felt- that's what sort of prompted Razzle. And then also after about 6 to 8 months of doing doing that, After.js is basically the way I've been fetching data abstracted into a library of components.

[00:06:37] Michael Jackson: You know, I've been uh I'm actually really glad that you built uh you know Razzle and After.js. Uh Ryan had had had built something back in the day called the React Router Mega Demo. And there were a couple of uh a couple of people I know who just like- did you ever see that thing, the React Router Mega Demo?

[00:06:56] Jared Palmer: Yeah, yeah, yeah.

[00:06:57] Michael Jackson: It was for like early versions of React Router. And I know a couple of people just kind of forked that thing and like made their whole sites from it. You know, um, I I talked to uh I talked to uh Mark uh Dalgleish down in Melbourne, Australia, and he he's uh he was building uh you know his whole product to basically, he was like, yeah, we just forked uh that thing and and and just built our product based on that. I think in general, uh a lot of people have kind of had this question about like, okay, so React Router, we're using it, how do we do server-side rendering with it? How do we, you know, tie it into the rest of our, you know, the rest of the app that that we're building here? Um, and nowadays, whenever anybody asks me that question, I just, I just point them to After. I'm like, well, this guy did it. Take a look. Um, so anyways, it was- that's a thank you from me.

[00:07:47] Jared Palmer: No, you're very welcome. Actually, After came from like, I saw a gist because I stalk Ryan's gists all the time. Um, it's one of my favorite things to do. No, um, but um, he wrote it. But Ryan's got some great jests to to there. And he he did like this— he did a— uh when React Router 4 obviously came out, it was pretty controversial. Um, I once I I got the hang of it, I like saw the light. But um people were still really confused about static route configuration.

[00:08:16] Michael Jackson: Mhm.

[00:08:17] Jared Palmer: Right? Like and and and still they are pretty confused about it. Because in the concept of React Router 4, for everyone who's listening here that hasn't played with it yet, um. What a route means to React Router 4 is very different than what a route means in other frameworks and such, and even other libraries in React. Um, it's just a component. And so, wrapping your head around that takes a second. And one of the cool like demonstrations, which to you to you and Ryan's credit, you guys sort of had in mind, which is that like even with components, you can have you can do static analysis. And so, that's where this example sort of demonstrated how to like take an array of your components, run through it. Um, maybe grab-

[00:08:56] Michael Jackson: But I mean, we do that all the time, right? You you you go and you fetch some data from the server or whatever. And maybe you've got a list of items that you want to render. And so, you know, in your render method, you just sort of map through those and churn out a bunch of list items or whatever.

[00:09:08] Jared Palmer: It's yeah, it's it's not too much different. The only I mean gotcha, I guess, is um back to the ES6 part of all this is um I like to co-locate the data fetch with the component itself. Similar to the way Next.js works with and I do that with a static method, just like getInitialProps. That's really one of their super brilliant ideas of of Next. And that's where you copy that into into after. But you know, you could just put that on your array. Like whatever the the promise is gonna be that you're returning to get your data or your initial props. You know, that could be put anywhere. Um, there are actually some benefits to not putting it on the component, believe it or not, which is kind of interesting.

[00:09:42] Michael Jackson: Oh, for sure.

[00:09:43] Jared Palmer: You could do you could put it in because that allows you to like sideload it while you're lazily loading the component and such.

[00:09:48] Michael Jackson: So you're talking about keeping the, for example, the query for your data separate from the component that actually needs it? Is that?

[00:09:55] Jared Palmer: Right, because then you can basically load the component up um lazily while you're also like in parallel fetching data for it. Um if you make it a static property on that component. Exactly.

[00:10:06] Michael Jackson: Yeah.

[00:10:07] Jared Palmer: Um some of the things I've been thinking about with After. Um

[00:10:10] Michael Jackson: so so so let's talk about After. Um because you know it's it's built as kind of a a Razzle plugin. Is that right?

[00:10:18] Jared Palmer: Yeah. So initially when I did it, I was kind of lazy. Well, initially when I did it, I was like, okay, like. There was- I'm gonna just do some- I'm gonna take like Razzle and like I basically copied and pasted most like 85% of the code and messed with the paths to like make it work with After and like make like just starting it up really easily. And that's- it was like basically immediately after I shipped it, I was like, that doesn't make sense to have two of my projects share 85% of the same code. Like, that's nuts. Um, so then I rewrote After with TypeScript and ended up just publishing it as the components parts and making a starter, a sort of like a a starter example with, with Razzle. Um, but yeah, so it took out the build system. It was sort of outside of the scope of the project and unnecessary. But um, still, yeah, exactly that. It basically gives you everything you need out of the box to have dynamic server rendering with React, React Router uh 4 and um, uh lazy um, or code splitting, code split routes.

[00:11:21] Michael Jackson: Yeah, yeah, it's, it's cool. You know, we, uh, you know, when we were writing the React Router docs, Uh, I think at a certain point, uh, you know, Ryan just sort of kind of punted on it and was like, you know what, if you're if you're doing code splitting and you're doing server rendering, like, good luck, basically. Um, because there are a lot of there are a lot of questions there, right? Like, how do you, you know, are you going to code split based on routes? Are you going to code split based on the components? Um, what kinds of decisions did you make uh when when you were doing After?

[00:11:55] Jared Palmer: Uh, that's a great question. One of the things that in the initial project guidelines was that it must work well with TypeScript. And we use TypeScript all the time. I like TypeScript a lot. I'm excited to see where this Babel 7 plugin for TypeScript um or preset goes. That would help a lot. But for the moment, like we're still using regular TypeScript compiler. And what that means is certain libraries such as uh React Loadable, which is uh really, really popular for code splitting, requires a Babel plugin. But for After, I wanted to make it so that it would work with code splitting but not require a Babel plugin per se. So it would be compatible with our infrastructure. And that means basically that I used um perhaps not as a- I used the Airbnb method, basically, is what I like to call it. Uh there's a great article on Medium uh about how Airbnb does code splitting now.

[00:12:45] Michael Jackson: Yep, I've read that.

[00:12:45] Jared Palmer: Um and it's this very similar method to that. Where basically you ensure the route is ready on the client.

[00:12:51] Michael Jackson: So you're not actually using Babel then?

[00:12:54] Jared Palmer: Nope. Not- well, well, by default, you- by default, Razzle ships with Babel, but on our projects, we actually remove the plugin, the Babel plugin entirely because it slows it down.

[00:13:04] Michael Jackson: Yeah, yeah, yeah. And you're using TypeScript.

[00:13:06] Jared Palmer: Yeah.

[00:13:07] Michael Jackson: How has that been going? I mean, that's- I feel like that's a whole new- like, that's a whole new can of worms, right?

[00:13:14] Jared Palmer: Yeah, um, I probably need to write a blog post about it, but we- I was using uh Flow and I think Flow is a great, great thing. But, you know, we took- we had like uh a moment where we looked at our- our- the number of third-party modules that we had in our projects that were typed by the community and versus the number of untyped modules. And if you've ever gone through the fun and pleasure of of adding your types to code that you didn't write, um, it's- it can be painful. And downright confusing, to be to be fair. Um, and then we looked at the TypeScript ecosystem and just, you know, if you go to Google as a proxy, if you go to Google and search like TypeScript versus Flowtype searches, or if you look at npm installs, you know, it's 10 to 12x the size. And so just from an ecosystem perspective, we we like just looked at how many modules were had full community support uh or community types for, and it was like 85%.

[00:14:11] Michael Jackson: Yeah.

[00:14:12] Jared Palmer: And the other thing I'd say about TypeScript, and I think is nice, is that uh Flow is really, really good, uh has better— I probably as you'd say better type inferencing. But what I found at least, and this is just my personal opinion, is that by like trying to have better type inferencing, it sometimes means that the errors are like not co-located where the actual problem is. Uh whereas TypeScript, where it's like not as perhaps as advanced of a type inferencing system. Like it, it's wherever the error is basically is like where the type, wherever the the the the error message tells you it is, is like where it actually is. But that also might have been my like naivete about type about about Flow in general. But that sort of was my experience with it.

[00:14:56] Michael Jackson: That's incredibly valuable, right? Like uh just the— it's it's so often like overlooked, but um I think uh Vijay was the one who first described it as you know developer experience or DX, right? Like just just uh uh and and I've seen you know lots and lots of stuff from people who will you know they'll they'll like apparently Elm. Uh I haven't done a lot of Elm, but I've seen a couple of like Elm uh you know screenshots from the compiler where it's just like you know in human language, like just really nice and telling you like, hey, there's a problem with your code right here. You probably meant this or that kind of thing, you know?

[00:15:37] Jared Palmer: Absolutely. I think that's like, talk about developer experience. That is like the pinnacle of it. Error messages are huge. I mean- Yeah.

[00:15:44] Michael Jackson: When stuff goes wrong. Yeah. I mean, that was one of the things about React itself that, that I really loved, you know, I mean, previous to to React, you know, you might get a blank page or or uh you know something wouldn't work and and you open the console and nothing, right? Um one of the things that I love the most about uh React is you just get these nice error messages right there in the console.

[00:16:11] Jared Palmer: Absolutely. Also, React empowers like library authors to write great error messages. Like one of the things like Informic that I do-

[00:16:19] Michael Jackson: The community has followed suit, right? The community has sort of followed that example. Yeah.

[00:16:23] Jared Palmer: Exactly. Like um what I use in in Formic, it's a form library. If you forget to pass a certain prop, uh which is like you need a name prop to for Formic to figure out like what field you're trying to operate on. If you forget that, like I just take the outer HTML from the synthetic event that React gives me and I print it to the console and so I show you which input it is.

[00:16:47] Michael Jackson: Oh, wow.

[00:16:49] Jared Palmer: So that one right

[00:16:51] Michael Jackson: there.

[00:16:51] Jared Palmer: It's that one with that class name. Exactly.

[00:16:54] Michael Jackson: That's awesome.

[00:16:55] Jared Palmer: So yeah, just but to to your point, like with TypeScript, it's like I don't know if they're they're they're they're necessarily like like more human readable, but they just tend to be more like co-located to the actual problem, which is super, super, super big. Um and then, you know, to be fair though, the biggest thing is the community. Like the TypeScript community is huge, has all the Angular guys behind it and girls and stuff. And so that's awesome.

[00:17:18] Michael Jackson: Yeah. Yeah, agree. So we kind of we kind of segued a little bit there into Formic, didn't we? That was another uh library that I wanted to that I wanted to talk to you about. Forms without the tears is the is the tagline for Formic. So I'd imagine in the in the line of work that you're in, you said you guys do a lot of client work, um there's probably a lot of forms.

[00:17:44] Jared Palmer: Oh yeah.

[00:17:44] Michael Jackson: Yeah. And so so you were you were somebody who felt that pain firsthand and decided to scratch again, scratch your own itch.

[00:17:53] Jared Palmer: Exactly. So what happened was, uh I think Dan tweeted this out. He was like, what was what should we work on in React? And like context and state management, you know, the the the obvious ones were there. But then also in the like the gathered responses was forms. Around the time of that, I was starting on this massive administrative dashboard, basically a big CRUD app too, and I was gonna have like 30, 40 forms. And quite quickly it became obvious that like we should pick a validation library and just stick with that. Yeah, that was like step one. And then after that it was like I found this, this Higher Order component written by Brent Jackson, who, you know, is a, is a prolific open source like force at this point.

[00:18:36] Michael Jackson: For

[00:18:37] Jared Palmer: sure. And it was, I think one of his examples, he just had this like tiny um higher-order higher-order component that was written with uh recompose and it kept track of value and and and um values and touched. And it was for like a form and it was pretty cool. And I started with that and then that sort of, I I took out the recompose eventually and ended up building this like tiny helper that just kept track of values. Uh errors and touched state for all your inputs.

[00:19:07] Michael Jackson: Okay.

[00:19:08] Jared Palmer: And it just initially, I didn't even like pass context or anything like that. It just passed down props. Um, and then you uh passed down props for the state. And then also, it had like you could reuse hand the handlers. So, um, you well, it was pretty in in React, even in the docs, it shows you in forms, like if you want to uh save some time, you can reuse the same change handler by using um an ES6 um trick where you take the event.target.name and you make that the the key at which you're going to update state. Right. And you pass that around. So that's basically what Formic did in the beginning.

[00:19:46] Michael Jackson: Then you just keep all the values in state of all the fields in the form.

[00:19:49] Jared Palmer: And you just wire that up um as needed. And then just again, it used the name the name attribute. Vite was just like kind of working, left it uh sort of with all our projects, sort of let it like we dogfooded it um on our own. And then I was like, okay, I was like, there's July 4th and I was like, I think it's time to to to really uh to push this out. So I pushed it out and it from from there it sort of grew into a whole different animal. Now it does stuff with arrays, which was the biggest, the the latest release. And now there's this cool pub/sub thing I'm working on.

[00:20:20] Michael Jackson: And you've got with Formik, you decided to offer both. You've got a higher-order component here and you got a render prop.

[00:20:27] Jared Palmer: Yeah. So first it was a it was a higher-order component, then it was a render prop when I I sort of saw the the light. Um,

[00:20:35] Michael Jackson: yeah,

[00:20:35] Jared Palmer: and it still it still is a higher-order component. And um, but it's it uses the React Router trick where you can make a higher-order component with a render

[00:20:43] Michael Jackson: prop. Nice. So so how has— so you're writing all your forms with Formic now?

[00:20:48] Jared Palmer: Yeah. Uh, well, I wouldn't say that. So like, I think Formic— I think people want Formic to be the Like for every single form, but I really still think it's for about 85%.

[00:20:58] Michael Jackson: Yep. I like that. So some forms you're just gonna say, you know what, I just don't need this.

[00:21:03] Jared Palmer: I mean, yeah. Yes, absolutely.

[00:21:06] Michael Jackson: I mean, so, I mean, I say that about some apps, right, that that don't need React Router. I'm like, like I built several apps without React Router after having written React Router, right? It was like, you know what, this app just doesn't need it. Like it's a single page app or it's a or maybe it's got like 1 or 2 pages, right? Like it's not a big uh thing that needs a lot of like routing. I mean, when you talk about uh you know the router, we can prevent navigation and we've got like you know prompts and things like that and and and redirects and things. And and if you're not doing any of that kind of thing, like maybe all you need is a couple of links, right?

[00:21:44] Jared Palmer: Totally. Um you know being able to, I I think some some examples of things like you don't want to use Formic for like If you have like a search bar, right? Like or like if there's no validation, um yes, it's a very quick way to to wire up um bidirectional state. But at the same time, like-

[00:22:03] Michael Jackson: Maybe I just need a couple default values and then they submit and we're fine, you know?

[00:22:07] Jared Palmer: Exactly. There are there are times when it's it's probably overkill.

[00:22:10] Michael Jackson: So you'd say it works it works best in situations when- finish that.

[00:22:15] Jared Palmer: You want to have extremely rich validation and logic without the boilerplate.

[00:22:23] Michael Jackson: Yep. I like that. I like that. Um, and so you said you were building it actually for like a big dashboard.

[00:22:30] Jared Palmer: Yeah, well, it was like a big CRUD app that was like like probably 15 or 16 unique views with forms. And so with like lots of business logic and stuff. And so it was it was It wasn't one of those things where there was a-

[00:22:46] Michael Jackson: I'm cringing over here.

[00:22:47] Jared Palmer: Yeah, yeah. It was one of those things where it seemed like almost day 3, it was like, oh my gosh, we need to standardize this. First it was- and we started at the bottom. We started by standardizing our inputs and our CSS class and all that. And then it was like, well, we really need to figure out how we like get the data into our forms and standardize that too. Because that's basically the 3 things that Formic like really, really, really excels at is helping you put a process around transforming your uh props into form state and then getting the form state back out, um whether that's sending it up to an API or using that elsewhere in your application. Like that's and just by and then by doing so as a second order effect, you end up standardizing your inputs and making those super reusable because they all have the same interface and like they're you know little things like a different name for a change handler in your- or for a prop, like, can be really annoying to keep track of, like, across a codebase or across a team. So just like by standardizing that too, you end up getting like a lot of benefit from just doing those little things. Um, and that's sort of where it started and and grew from.

[00:23:58] Michael Jackson: Cool. Yeah, I like uh naming things, right? Consistent naming of things is huge, uh especially when you're working on a on a team. Well, awesome. So so we've man we've covered a lot of ground. I feel like we've talked about, uh you know, just about just about uh everything that that you're working on these days. Is there is there anything that I have left out? Just browsing around your GitHub page, there's uh oh, there's React Functions.

[00:24:26] Jared Palmer: Oh yeah.

[00:24:27] Michael Jackson: That one's pretty cool.

[00:24:28] Jared Palmer: Yeah, it's it's fun. That that that was like, what ended up happening was, um fun fun fact for those listening, I started working on that while I was at a React training uh seminar. So Oh, nice. Yeah. So, I I I I dropped in on Ryan's seminar in the city.

[00:24:45] Michael Jackson: Okay.

[00:24:46] Jared Palmer: Um, and there was a part of it where he was going over- it was something in the scroll component, which is a render prop. And I was like, uh, scroll, this would be— uh, and I had just in in in a couple other applications done my own like geo position component that's also was also very similar to the one being demonstrated. And so, I was like, Somebody should just get all go through MDN, the Mozilla Developer Docs, and just like-

[00:25:11] Michael Jackson: All those imperative APIs, right?

[00:25:13] Jared Palmer: All of them and just knock them out. And then I would and then like that would be easy to install. Uh 'cause I had like geo position in like 4 different projects of mine. And so that's where I was like, ah, I should probably start this out. So

[00:25:25] Michael Jackson: you've got geo position, you've got scroll position, you've got you know media queries, listening to those things. Um, you know, the the the network, online, offline uh APIs. You've got so, so many uh you know imperative APIs that the browser has built in and you've basically taken them all and made them, uh you know, just wrapped them in React components. Never have to do it again. Now I've got a component for that, right?

[00:25:53] Jared Palmer: And that's what's so beautiful about React. Um, it just makes that, you know, you you you're talking the at the New York meetup, you touched on this, like. By remove by just by by making anything that seems imperative, you can put it into its own component at this point. And I think that's such an awesome, awesome paradigm and way to look at the to to way of looking at UIs.

[00:26:14] Michael Jackson: Yeah, it's you know and and it's just like building little little abstractions on top, right? Like we don't need to build like a ton of stuff, but if I can just make a little component that models this imperative behavior in a declarative way, Now it's you know super reusable. I can give it to somebody else. They can reuse it in their app. And and I can also- one one other thing that I love about using these components is, you know, if I'm looking through your render method and I see a network component or a media component or, you know, a a a scroll position component, right, that these these components that are modeling these imperative behaviors. It immediately communicates to me what that component is doing, you know, what its job is, um, instead of instead of just like a onScroll handler or uh, you know, on uh or or or or some like code hidden away in a componentDidMount that's doing, you know, some imperative work, um, you know, listening for network changing or for a query string, or sorry, a media query changing or something like that. So Yeah, that's that's awesome. That's super awesome.

[00:27:22] Jared Palmer: Yeah, I think I think it's one of those— um I I always strive to be very declarative and and and and whenever I'm writing, move stuff to the render method. I think it's gonna be really interesting. I'm curious about your take on this too, uh when the async um stuff lands and what then and the stuff that's gonna move into render that has traditionally hasn't been there.

[00:27:42] Michael Jackson: Yeah, you know, it's funny. The more I talk to the React team about the async stuff that they're doing, and the more I'm like I'm watching the the RFCs coming through in the you know the React.js RFCs repo, um the more I'm I'm reading through and learning about really what they have in store, I'm looking at the entire React ecosystem and I'm thinking a lot of this is gonna change.

[00:28:13] Jared Palmer: Oh yeah, it's it's gonna be it's gonna be

[00:28:16] Michael Jackson: yeah it's

[00:28:17] Jared Palmer: yeah world changing.

[00:28:18] Michael Jackson: Everything needs to sort of change to become async aware. And and and I don't wanna I don't wanna alarm anybody and say that like stuff's gonna break because it's not. The the React team-

[00:28:29] Jared Palmer: Everything is gonna break. No, I'm just kidding.

[00:28:32] Michael Jackson: No,

[00:28:32] Jared Palmer: there's I think there's gonna be different problems and I think that's a big that's a big deal, right? Because we have so many components and helper libraries. And patterns that have emerged to solve this like React synchronous problems.

[00:28:46] Michael Jackson: Well, and

[00:28:48] Jared Palmer: I just think that,

[00:28:48] Michael Jackson: yeah, there are different patterns emerging uh as everything- as we start to put async first, right? Um so for anybody listening, um you know, I should probably, you know, say what we mean by async. Um I mean, as far as as far as I've seen, uh basically you know, asynchronous in React, or or that you know you've also heard of React Fiber. It's basically the the ability that React has to um basically to prioritize different kinds of rendering, right? And so, you know, some rendering uh is is higher priority, um and some has lower priority. And uh some rendering, you know, needs to happen after You know, you do a fetch for some data and uh you know maybe it's maybe it's um or you know a fetch for for an image and you decode the image in the browser and only then are you actually ready to render that thing, right? And so so you know traditionally, um you know we haven't really, uh at least not to my knowledge, front-end uh UI JavaScript frameworks have haven't really tackled that problem head-on or or or haven't really um invented any really good primitives for solving that problem, right? It's just kind of like, well, you know, if you're gonna fetch an image and it's gonna display, um, you know, put a height on it so that you won't trigger a re-layout when that image finally loads. Um, can we can we do better than that, right? Can we can we avoid the flash of content um altogether? Um and and how can we do that? Some obviously, you know, some fetch operations, uh, and and it's hard to generalize because some fetch operations you want to sort of show a change immediately, some you want to do in the background, some you want to delay until the data that uh that you want to display is is ready to show. Um, so anyway, anyway, uh, there are a lot of things to think about. I I just think that um the the one thing that I think is really going to to sort of save us and make this whole thing very, very easy Uh, is the fact that we are all programming with components now. Um, and people who who've listened to anything else that I've said uh probably get tired of hearing me say this, but like just use components, right? Um, if you if you're using uh components, uh then you're you're programming within the React paradigm, right? You're programming within the React model. Um, and the React team themselves are going to be shipping components uh to to help address some of these problems and to help to solve uh some of these problems. I think we saw in the uh in the new context context sorry API uh that Andrew Clark uh proposed, um which uh was based on uh the React broadcast API. You know it's it's just it's just components uh with a render prop. And uh I think that as long as you know as long as you're building components, as long as I'm building components, as long as people are building their apps with components, the uh the path to migrate forward will be fairly clear. And and it also makes it a lot easier to you know to automate that process, do things like code mods and things, you know, because-

[00:32:08] Jared Palmer: Yeah, I think they're gonna need to do some of that for sure. The code mod stuff, like I think I think the thing that gets me kind of like my mind really spinning is moving fetches into render. Like that is- that seems so antithetical to what I'm used to seeing and yet such a good idea at the same time. It's just like, I don't know, finally getting used to looking at a component and knowing where everything is.

[00:32:34] Michael Jackson: Absolutely.

[00:32:35] Jared Palmer: I mean, I don't know, you know, I don't know if you, but then moving some of that logic into render is gonna be wild, I think.

[00:32:42] Michael Jackson: It'll be it'll be exciting to see how it all plays out. I think uh I think you know some of that stuff, it's it's already into uh the React codebase. Some of it is is going to be released in 16.3 and then um and then you know even more in in the next major version. So.

[00:32:59] Jared Palmer: Yeah. Like thinking about what React 18 or 19 is gonna look like is is a fun exercise.

[00:33:05] Michael Jackson: Yeah, yeah, yeah.

[00:33:06] Jared Palmer: Um it's it's certainly a cool uh different a cool pro- look, there's big money on the line from if if you're Facebook, if you're you know if you're in in in really pushing the limits to this to this stuff. And certainly uh async rendering is gonna be a he open the door for uh uh an enormous amount of new UI uh possibilities.

[00:33:27] Michael Jackson: I I'm personally just stoked that that uh the Facebook team is actually you know thinking about these problems and solving them uh on on on a fundamental level. Because You know, they're they're they're they're not scared of it. Like they're not just punting on it. They're not pretending like these problems don't exist. They're they're facing them head on and saying, okay, so how do we, you know, how do we take that user experience that we've got right now on the web and take it to the next level? And maybe we can provide a couple of primitives that are gonna help people, um, you know, to to be able to, you know, we used to say that React, you know, helped you fall into the pit of success. Um well, there's still like this very scary async land where, you know, it's not very easy to fall into the pit of success. And I think uh I think maybe they can make that a little bit easier with uh with a couple of components. Um my goal actually is one of my goals is to get Andrew Clark on here before too long. Uh I've already talked to him about coming onto the podcast and get him on here and and just really-

[00:34:31] Jared Palmer: He's working on some cool stuff.

[00:34:32] Michael Jackson: Yeah, just really dive deep into like, okay, So what, you know, what what is this gonna look like? And and you know, what are the what are the problems that they've been that they've been facing? All right. Well, Jared, hey man, it is always a pleasure talking to you. Thank you so much for uh for coming on the podcast. And um anything uh anything else that you wanted to kind of give a, you know, give a shout out or say anything else before we wind it up?

[00:34:56] Jared Palmer: No, I think that's uh covered it. You know, I'm truly, truly thankful that uh Took the time out of your day to to to to spend with me. It was great.

[00:35:03] Michael Jackson: Yeah, yeah, no worries. So so uh again, Jared Palmer, he's with the Palmer Group in New York City. He's @jaredpalmer on Twitter, I believe. I followed you like a long, long time ago, so I I I forget the uh the Twitter handles. @jaredpalmer on Twitter and on GitHub. And thank you so much, Jared, and we will see you next time on the React Podcast.