81: Evan Bacon on Expo and the Future of "Build Once; Run Anywhere"
Today we chat with Evan Bacon about Expo and delivering on the elusive promise of "write once. run anywhere."
For the month of february, we're chatting exclusively with Reactathon speakers.
You can hear more from Evan on the topic of using Expo for universal React development this march.
Reactathon is a top React conference in the heart of San Francisco.
Evan and I will be there, having a good time and happy to chat with you.
Get a ticket at reactathon.com.
Featuring
Links
- Life Size Lego Thor Build!
- Expo — The fastest way to build an app
- James Ide
- Brent Vatne
- React Native
- Software Mansion
- React Native for Web by Nicolas Gallagher
- react-native-dom
- microsoft/react-native-windows — A framework for building native Windows apps with React
- Metro — 🚇 The JavaScript bundler for React Native
- Introducing Twitter Lite on the Twitter engineering blog
- react-native-web-hooks
- react-spring
- Animated (React Native)
- Expo Crossy Road source and site
- Expogram source and site
- jest-expo
- jest-expo-enzyme
- jest-expo-puppeteer
- Expo on Twitter
Transcript
[00:00:00] Michael Chan: This is React Podcast. I'm Chantastic. This is episode 81 of React Podcast. Today we chat with Evan Bacon about Expo and delivering on the elusive promise of write once, run anywhere. For the month of February, we're chatting exclusively with Reactathon speakers. You can hear more from Evan on the topic of using Expo for universal React development this March. Reactathon is a top React conference in the heart of San Francisco. Evan and I will be there having a good time and happy to chat with you. Get a ticket at reactathon.com. Evan Bacon, welcome to React Podcast.
[00:00:48] Evan Bacon: What's up, Michael?
[00:00:49] Michael Chan: Hey, so as far as I know, uh, you're the first Master LEGO Builder to ever be on React Podcast. Tell me how you got that title uh over you and like, you know, what you've been doing with LEGO.
[00:01:02] Evan Bacon: Uh, yeah. So, uh, I started doing Lego Lego art, I guess, when I was uh 11, 12 years old. I just wanted to like have a life-size Lego Batman sculpture in my house. I'm not sure why. Yeah, so then I did it and uh it took a few months and people were just really interested in it. I guess I like doing very meticulous detail-oriented things.
[00:01:25] Michael Chan: Yeah.
[00:01:26] Evan Bacon: And then, uh, yeah, I just kind of kept with that like. I wanted to have a life-size Iron Man and Superman. After a while, like I got invited to go to conferences and stuff and show off Legos. And uh after a while, I guess it was just like doing it professionally and I kind of grew into it. And uh yeah, now I'm a a Lego Master Builder and a programmer as well.
[00:01:45] Michael Chan: That's amazing. So you still do the Lego building?
[00:01:48] Evan Bacon: Yeah, whenever I have time. I love doing Lego art.
[00:01:51] Michael Chan: Oh man, that is amazing. So this is kind of like a random question, but like So you're building a life-size thing, right? And like, how much does, you know, like a 30,000-piece like sculpture- like, what does that cost you as like a, as like a hobby to build something like that?
[00:02:08] Evan Bacon: A ton of money. Like, so much money. Uh, when I was younger, I had like a warehouse job and I would do like sanitation. So I would just- I like carried trash down to the- just so I could like take all of that money and invest it right back into Legos. And I could only build like so much at a time because then I like would run out. Uh Legos are really expensive and they they've gotten even more expensive over the years, so it's uh it's pricey.
[00:02:33] Michael Chan: Man, that's wild. Do do do does Lego like sponsor people who are doing some of these like life-size things?
[00:02:39] Evan Bacon: Yeah, I think they they sponsor a few people. Uh at the time when I was mostly doing it, uh I was too young for a sponsorship, so they told me I needed to be like 18 or older. Okay. At the time, I was like, yeah, I don't know if I'll be doing LEGO stuff when I'm like an adult. Uh, but now I just pay for it with my software money, my open source money.
[00:03:02] Michael Chan: That's awesome. That's awesome. Well, I uh I I loved as I was I was researching you, it was fun to find your YouTube channel and see kind of this this cross-section of your interests, both you know programming and uh doing the doing the LEGO stuff. So the the the Master Builder, like or Master LEGO Builder, like what does it take to actually get that- get like that and what is it?
[00:03:26] Evan Bacon: So, a LEGO Master Builder, I think officially LEGO has Master Builders who work at LEGO and they make sculptures uh all day. And then there are the things called like LEGO Certified Professionals, which are the people who don't necessarily work at LEGO but they do have contracts with LEGO. Uh I am neither of those two things. Uh I just got really popular on the internet and people just started calling me LEGO Master Builder.
[00:03:51] Michael Chan: Oh, nice, nice.
[00:03:51] Evan Bacon: Yeah, yeah. So, uh, it's totally made up. It completely has no validity behind it. There's no certificate or- it's kind of like my open source, uh, professionalism. It's just kind of like, uh-
[00:04:02] Michael Chan: It's a thing that you just kind of grow into.
[00:04:05] Evan Bacon: Yeah, I guess people are using my library now. I guess people- so now I'm an open source developer. And same with LEGOs, I, I guess now I'm, uh, a LEGO Master Builder.
[00:04:14] Michael Chan: Well, I love it. It was really fun to to see some of those videos. I've never seen uh I've never actually seen a life-size LEGO sculpture constructed. And so it was really fascinating to watch. Um so now getting into the more technical stuff, uh you work with Expo and you're a full-time open source developer. Uh tell me a little bit about how you got into that and connected with Expo.
[00:04:36] Evan Bacon: Right. So uh Coming out of Lego art, I I took a job as a designer at a company called Frog Design, which is a very big design corporation, kind of like IDEO. And uh I was working on lots of prototyping. I was a native developer at the time, so I was making like iOS and Android apps. And then uh eventually I was working with stuff like Ionic and uh Xamarin, and I found uh React Native. And at the time it wasn't very good. And then maybe like a few months later, my next project, I reapproached it and I found Expo. And it was incredible. Like, it made my job go like 4 times faster, and I barely had to do anything, and it was great. And I think after like a few projects of using Expo, uh, it started to set in that I had to like move on to other projects. And so I just kind of quit my job and started working full-time on developing Expo, and I've loved it. It's great.
[00:05:27] Michael Chan: Awesome. So were you able to work on Expo like first as like an external or like open source developer and then move into kind of a professional capacity with them?
[00:05:38] Evan Bacon: Yeah, so the capacity I joined Expo in was, uh, like I was making demos on the side along with my job just because I really enjoyed using Expo so much. And so I made like a lot of video games, like I made this Crossy Road clone and like a Minecraft clone with Expo. And so when I joined Expo, it was to do like product design and uh make demos and guides, and then, uh, okay, it just by happenstance, turned out that I also am a native developer and know JavaScript. So that worked out really well because now I I hardly make guides or tutorials and I mostly just work on native code.
[00:06:11] Michael Chan: That's awesome. Uh about how big is the team working on Expo right now?
[00:06:18] Evan Bacon: Hmm, I don't know. Uh maybe 15 people. And then we contract with uh Software Mansion, which is an incredible React Native uh consultant firm out of Krakow, Poland. Uh, the guy who runs Software Mansion, Krzysztof Majera, made React Android. So like React Native used to work only on iOS, and then he added Android support at Facebook. And so now they make like tons of great stuff. And uh, a lot of like- there are a bunch of people at Software Mansion who just work full-time on Expo. So we got a few people over there, and then we've got a bunch of people in Palo Alto, and there's a lot of remote workers. So like uh Brent Batney, who lives in Vancouver, and uh- Oh, wow. Villa, who lives in Finland, and lots of people.
[00:07:00] Michael Chan: Awesome, awesome. So I want to back up a little bit for anyone who's not familiar with Expo. Because I think the the audience for the show is predominantly web developers. And um if you could, give us like a high-level definition of like what Expo is and what it does.
[00:07:19] Evan Bacon: Right. So Expo is a universal platform for building applications with React and uh TypeScript or JavaScript. And it's it has a managed workflow and a bare workflow for the native apps. And then for the web apps, it uses React Native Web, which is something that I personally work on. And we'll get into that a little bit later. But for uh the longest time, it was just the iOS and Android- just iOS and Android. But it streamlined building iOS and Android. So there was a client app, which you can download from the App Store, and then you can load all of your React Native projects on that. Which is great because if you don't have a MacBook, then you can still do iOS development. Otherwise, you can't build onto your- like, if you have a Windows computer, which is a lot of the world. So we have a lot of people who are not American who can use Expo to finally develop iOS apps. And then there's a bunch of tools like a build service in the cloud, so you can do like expo build ios, and that'll build your IPA. Like, you don't have to do anything else. Oh wow. It's crazy. And like Expo Build Android, which will build an APK and give it to you, and then you can just send it off to the store. So it makes uh native development super easy and it's great. And then they build a lot of just the React Native community out. So like James Eade and Brent Bettany, who are kind of the some of the founders of Expo, they uh both were at one point, I think, like number one contributor on React Native. They work on tons of stuff. I mean, Brent Bettany, if you do React Native stuff, you'll see his name everywhere. He made like Camera, he works on React Navigation. Yeah. Uh, and yeah, so Expo just builds out a lot of the React Native community as well and helps to like make the modules that are required. So any module that is like an Expo module, like Expo Camera or React Navigation, these are all like work on any platform that Expo works on. So you can use Expo Camera on iOS, Android, or web. And if we had desktop, then desktop and things of that nature.
[00:09:08] Michael Chan: Interesting. So it sounds like From from someone like from uh someone from like an outside perspective, it sounds like there's a lot of framework tools that allow you to like-
[00:09:19] Evan Bacon: A lot of tooling.
[00:09:19] Michael Chan: —make the developer process, uh I I guess, more consistent. So, like like you said, if you don't have uh a a Mac, you can still develop an iOS app instead of having to kind of- because like React Native doesn't really solve that for you. It just it gives you the tooling to like make it possible, but you still have to have You know, like Xcode and all of the, the tools to actually build those applications.
[00:09:43] Evan Bacon: Right, right. And if you're using Expo at like a more like professional capacity, we do have like this bare workflow where you can drop down and then add native dependencies, but then naturally you need to like rebuild those onto your device. Interesting. So we also have things like this, uh, custom client that we're working on where you can request to have native modules added and built in a client. And things like that. Uh, and so it does have the ability to like drop down to what React Native provides, but for the most part, I think of React Native like a way to use JavaScript and React with native code. And then Expo adds all this tooling and like the CLI and all kind of things just that bring the best of web to native development. So it makes it a lot more approachable for web developers.
[00:10:25] Michael Chan: Interesting. Interesting. And so you said there's also a lot of like libraries that may be kind of like missing APIs from like just bare React Native?
[00:10:34] Evan Bacon: Right, uh, I like to think of React Native as a library, not a framework, even though it does have a lot of, you know, like, components built into it, which they're currently working on pulling out. Uh, it's, it's, it doesn't have things like the camera or the file system or the permissions, uh, constants, device, so much stuff. And so, uh, all of these things that you just need to build a real production-ready application, Expo provides all these things for you. Things like gestures and maps and videos. And um and you can use them all outside of the Expo ecosystem as well. Like if you just have a regular React Native project, you can install Expo Permissions and then use that to ask for permission to the camera or something.
[00:11:15] Michael Chan: So it sounds to me like— um I know that there's a lot of library confusion, you know, on like npm, like, you know, what the best library is for this and that. And it sounds to me like a differentiator of Expo libraries is that they're designed with uh cross-platform in mind. So, maybe it's not just gonna be web, it's not just gonna be like iOS or Android, um but you're designing them to be used on all of the platforms. Is that is that kind of a correct assumption?
[00:11:43] Evan Bacon: Yeah. So, a good example of this is we have like a standardized error pattern that we use. So, if functionality isn't available on a certain pattern, it will throw that kind of unified unavailability error and tell you maybe this isn't implemented or this just isn't available on certain platform. But yeah, they're designed in a way where like if we make a library, we want to kind of leave it flexible. So if we want to add desktop support in the future, we can do that and we don't have to change the overarching API, the front-facing API for people. Um, and then yeah, a big thing with Expo libraries is that like React Native is it's iOS and it's Android, right? And then there's these out-of-tree solutions like what Microsoft is doing with React Native Windows. And what Nicolas Gallagher did with React Native Web, which is incredible. So Expo creates libraries that work across any platform that has React Native. It's really just like a universal React rather than like a React Native setup. Okay,
[00:12:39] Michael Chan: interesting, interesting. So you're kind of taking what React Native is doing with the two-platform solution and extending it to even more platforms.
[00:12:47] Evan Bacon: Right, making it just work universally.
[00:12:49] Michael Chan: Interesting. So It's interesting. I've only just recently learned about uh Microsoft and kind of their investment into React Native. Um and that it sounds like they're doing both Office and a couple of Xbox projects um you know using React Native. Can you tell me a little bit more about React Native Windows and and how that fits into the ecosystem?
[00:13:13] Evan Bacon: Yeah, well, uh the stuff Microsoft's been doing with uh React Native is super exciting because They just, it seems like they're very excited about using it. They've put it into a bunch of products. Um, and the stuff that they're doing with Windows, it's really interesting. I think they're also working on like Electron at uh Microsoft.
[00:13:30] Michael Chan: Oh.
[00:13:30] Evan Bacon: Um, so the stuff that they're doing with Windows is really good. We are definitely like looking at Windows and considering it when we like model our APIs. Uh, but it all just seems like very, very straightforward. I know they're also doing a lot of cool stuff with like the bundlers, 'cause currently React Native uses Metro Bundler. And they've been doing a lot of stuff to make Webpack work with uh React Native.
[00:13:50] Michael Chan: Oh, cool.
[00:13:51] Evan Bacon: Yeah, which is really exciting as well.
[00:13:53] Michael Chan: Awesome. Awesome. Um, now you also mentioned uh React Native Web as one of these kind of additional targets, like beyond just the the the Android and iOS targets that React Native focuses on. Now I know that there's a lot of confusion about that project as a whole, like from the naming and everything.
[00:14:14] Evan Bacon: It's really just the name.
[00:14:17] Michael Chan: What is uh what is that for? Like what does it do with regard to React Native and the web?
[00:14:24] Evan Bacon: Right. So what React Native Web does- well, I guess like brief history lesson. React Native Web was created by Nicolas Gallagher, who made like Normalize CSS and has just been around making awesome open source for a long time. And he made it when he was at Twitter to create the Twitter Lite PWA. And uh now if you go onto Twitter, Uh, if you open the inspector, like React Native Web is just used for the Twitter website, which is like the 6th biggest website in the world, probably more than that now. And uh, yeah, it's it's just a very well-baked-out framework. Uh, what it has inside of it is it has like this really good stylesheet API, which is one of the fastest CSS-in-JS libraries available. It's got this really incredible accessibility library built into it, which uh gives you the ability to just very quickly like toggle right to left and other things of that accessibility nature. And it really turns accessibility accessibility like into a building block rather than kind of this thing that you add on later. So like for instance, if you want to make a link in React Native Web or just like React Native, um, what you would do on web is you would use like an anchor element. What you would do on React Native Web is you would use a a text element and then you would set the accessibility role to link. And when you do that, now it renders to an anchor element on web and then on iOS and Android, screen readers know that it's a link. So it's kind of like universal accessibility. So they do a lot of very clever things with it. And uh it's it's just a really fun library to work with. But yeah, the the name React Native for Web scares a lot of people off. I think just the word native is very scary and putting it in a a web framework uh is it's like a recipe for making people not wanna approach it. But uh it's it's a really great uh library and there's a ton of people who are using it. Like Major League Soccer uses it, the Times. And uh now it's if you make an Expo app, you get a React Native web app, uh which is kind of like wrapped, and then all the dev tools are taken care of for you. And uh it works very seamlessly.
[00:16:19] Michael Chan: Interesting. As someone who has primarily interacted with React DOM, which is probably the the bulk of like the React umbrella ecosystem-
[00:16:29] Evan Bacon: Yeah, it's basically what when people say React, they mean React DOM.
[00:16:33] Michael Chan: Totally. So like Coming from that experience, what can people expect trying to use React Native Web for the first time? Like what are some of those those initial roadblocks um that they might kind of find as they're like making a transition into this library?
[00:16:50] Evan Bacon: Right. So, uh so if you create an uh a new Expo project now, like expo init, you'll have like an app.js or an app.tsx. And in that file, uh You can really write whatever kind of React code you want. It just depends on like where you plan to run it, like what's the target, uh the target like browser or native. And so you could write React DOM code right into that. You could write like a p element, a div element, whatever you want. It just won't render natively. So you can import the primitives from React Native like View and Image and Text, or any of the primitives provided by Expo like camera or the gestures. And if you use any of those primitives, then they'll work across platform. So you can very slowly integrate it if you want, or you could switch right over to it. It's very like um incremental in the way that it's implemented. And if you want a certain file to only work on web and not work on native, you could use a file like a platform extension. So you could have app.web.ts or app.web.tsx or whatever. And then the bundler will look for that more platform-specific uh file name when it's building for a certain platform. So if you wanted to have like one module look one way and like a switch module or something, you could have switch.ts and then switch.web.ts, and one could be native and the web one could be, you know, just the the web code. And then none of that needs to be agnostic in that file. So you could go kind of incremental to whichever uh you know size you want.
[00:18:23] Michael Chan: Interesting. So if I understand correctly, one of the things that changes in this kind of style of developing is typically we go you go with the maybe new native primitives, which are which are a little bit more generic than the web ones that we're used to in React uh DOM. Um but then from there, you actually when you're creating custom components, use a different implementation for each of your platform extensions, um, to like actually implement that component specifically for the platform you're trying to target.
[00:18:56] Evan Bacon: Right. I think the main benefit of using something like that is that you can get really good tree shaking. So if there are a bunch of native dependencies you're implementing in one file and a bunch of web dependencies in another, then the bundler- like that works at the bundler level. So it knows how to remove all of the code from a platform that you're not using. Which is actually how the Expo modules are implemented internally. So they have the universal API layer and then there's like the native layers and the bundler knows how to remove all of those native layers. So you don't have any like overhead when you're building for a different platform.
[00:19:27] Michael Chan: Interesting. Super fascinating. So I know that you mentioned in React Native Web, one of the best parts of that is the uh is the stylesheet create function. So how does that uh diff- how is that different from some of the other implementations that we've we've seen either for web or the default one in React Native?
[00:19:47] Evan Bacon: Right, uh so the the React Native stylesheet and React Native Web is uh it's one of the fastest uh CSS-in-JS libraries around. There's actually a benchmark on React Native Web where you can test it against other CSS-in-JS libraries, which is super helpful. And um it it has a few shortcomings, I guess, and uh those are like you can't really do pseudo classes up front. So you have to use hooks for all of those.
[00:20:13] Michael Chan: Okay.
[00:20:13] Evan Bacon: And uh of course you could implement those specifically for the platform, but if you want it to be universal, you could use something like— uh I have a library called React Native Web Hooks, and then you can implement like use hover, and then that's just like a boolean, and then when the boolean is on, you use a certain style, and when it's off, you use other styles. And you can do that for like hover and active and focus and everything except visited, because apparently the visited has a security vulnerability. Because like you could load in a bunch of links onto a page with JS and then see if they've been visited or not without the user knowing. So like that's the only one.
[00:20:46] Michael Chan: Interesting. Things that you don't necessarily think about when you're just like kind of coming from CSS DOM land.
[00:20:55] Evan Bacon: Right. If like ever since I noticed that, every big website I go on now, they just don't have visited link styles and it all makes sense to me now.
[00:21:04] Michael Chan: Now I know that you had mentioned that this is kind of like, React Native Web is the tool that's used to support the web in Expo.
[00:21:13] Evan Bacon: Right.
[00:21:14] Michael Chan: And supporting this vision of write once, run everywhere. Now, obviously React Native Web is like an opinion of kind of how that mapping works out. Yeah. But there's always a possibility that something else might come up and kind of like usurp it, or maybe the React and React Native team are quietly working on some new thing that's gonna, you know, solve this problem for us. In the event that that happens, you're using Expo, like what does that look like to maybe replace, you know, React Native Web with, you know, some unknown future thing? Is that a possibility? Or um are we kind of betting like pretty hard on React Native Web right now?
[00:21:54] Evan Bacon: Uh yeah, I think React Native Web is is the way to go. So before I actually worked on Expo Web, we uh the Expo team met with the React Native team, the React team. Uh, I think it was mostly the React Native team. And uh Nicolas Gallagher was there, 'cause he actually works at Facebook now. Yeah. And um, uh we we just kind of discussed like the different options and approaches we could take, because uh even the React Native team wants web to be like a a a first-class citizen. So um, it's just something that we've like, you know, spoken to them about. I don't I don't think like uh if there was like a change of direction, We'd like probably communicate it with each other and something like that.
[00:22:32] Michael Chan: Awesome, awesome. Yeah, and like I'm asking mostly because I know that sometimes, you know, there can be a lot of concern around like changing your toolchain, especially in something like this where it's like you're changing the way that you actually write components. And that can be like super scary. And uh a lot of times it's scariest because the future is unforeseen. And so I'm just kind of curious, like What kind of conversations, like like you mentioned, have like gone into actually choosing that as the the the path forward to this, you know, write once, run everywhere type of future?
[00:23:06] Evan Bacon: Yeah, well, so I think running web with React Native, there are like two really good options. Uh one was React Native Web by Nick, and then the other was uh React Native DOM by uh Vincent Riemer, who's uh super awesome, lives in the Bay Area. He's actually also works at Facebook now. Um, and so we were kind of going back and forth on those two choices, and I think we just kind of landed on React Native Web. Uh, it's a very proven technology and it's it's very well baked out. Like, React Native DOM is very promising and it has a lot of interesting implementations in it, uh, but it like there's just so much more to do with it. And so, uh, we kind of went with React Native Web. And even when we went with it like a year ago, there's still been so much to do to get it to a place where it feels like you can just use it in co-op with React Native for mobile.
[00:23:56] Michael Chan: Yeah. So for people who are are are interested in this, are you working with, you know, the maintainers of React Native Web in in order to kind of make this all work together in Expo?
[00:24:09] Evan Bacon: Uh yeah, yeah. Uh so like whenever there's uh an implementation of an Expo feature that kind of overlaps with the React Native proper feature, we'll like talk with Nicolas Gallagher about it. Uh he does a lot of the maintenance himself actually, which is really exciting. I noticed he was actually the first guest on your show, so it's awesome. Uh I'm a huge fan of Nick Gallagher, by the way, so it's cool that I get to work with him now. Oh, he's amazing. Yeah, he's awesome. Uh so yeah, uh currently there's a big movement called like Lean Core where they're pulling a lot of modules out of React Native, and so they need to do that same thing with React Native Web. So there's kind of some back and forth there about like how those will be combined, because currently React Native and React Native Web are two separate packages. But with all the Expo packages and kind of some of these newer modules, we probably want to combine like the web and every, every platform into one module. So with the Expo modules like Expo Camera, all of the web code and the native code lives in the same package. And then the Expo webpack config, like our default webpack config, knows how to tree shake out all of the like native or web code that you're not using. Uh so there's a lot that goes into tooling, which is really the kind of the big thing that Expo CLI adds to the the web workflow is uh before you need to like know a lot about webpack config and Babel and tree shaking. And uh with this, you don't need to know anything about them. You can just go and set it up and get started.
[00:25:37] Michael Chan: That's interesting because it it seems like you could maybe easily implement a naive version of all of this yourself and support the two platforms, but you might be sending, you know, the full implementation for everything to like every customer.
[00:25:51] Evan Bacon: Yeah. Uh, and I think a lot of people were actually doing that for the longest time. So when I started on the project, there was like this really funny bug, which it's funny because, uh, I think no very good, like strict developer would run into this problem. But myself as a hobbyist, kind of, uh, I hit this problem a lot. And the problem is with React Native Web, if you imported a module which wasn't implemented on web, like TabBar iOS, then it would break all of tree shaking and you wouldn't know. It just like wouldn't be clear, and then it would import everything. Yeah. And it's, it's funny because, yeah, I think like no one who is very good would import a module that just doesn't work And I'd be like, yeah, see if this works. And then it does. And then I had to like go through and debug like webpack bundle analyzer, why my bundle is massive. So yeah, now uh tree shaking is a lot more resilient in React Native Web. That problem doesn't happen if you import something which isn't implemented. It it just uh it still tree shakes it out. And uh yeah, there's a ton of tree shaking that goes into making everything work. Uh and we actually just— uh I just announced uh Preact support. Uh earlier this week.
[00:26:59] Michael Chan: Oh, wow.
[00:27:00] Evan Bacon: Yeah, which is really exciting because it cuts the the default bundle size in half. So, uh yeah, it's it's really exciting. Amazing. Yeah, I'm I'm a big like bundle size advocate fan person. I really big on keeping it keeping it minimal.
[00:27:16] Michael Chan: Nice. Now, I know that another concern that a lot of people have is— and and and when I say a lot of people, I mean myself included. Like anytime I see like cool tooling like this, like I want to know if it can work with um you know X framework that I'm already using, right? Like I use Next a lot. I'm like I I I want to make sure that I can continue to use this um while maybe getting the other benefits of all this really cool tooling that you're working on. Uh how does it look to integrate Expo with other frameworks like Next or whatever else?
[00:27:49] Evan Bacon: Yeah. So I think uh some big frameworks that people really wanted when I started talking about working on this project was uh like Gatsby, Storybook, Next.js, and uh I think just things like Jest, uh really all the tools that people are very used to using. Uh styled-components is another one. And um I think just figuring out how to make all those work together is really important. Because if you look at other cross-platform solutions outside of React Native, like uh Flutter for instance, there's Flutter Web, but it doesn't support SSR and it kind of is like its own thing. And the thing with the web is like- Yeah. There's so many years of just like genius that's poured into like everything and all these incredible frameworks. And so we wanted to integrate- like, that was a first-class kind of need, is that it should integrate with all of your favorite tools right out of the box. Yeah. So uh you can integrate with Gatsby and Electron and Storybook, and uh we're still like working through Next. Actually, you can like start and build with Next. There's some features that I'm still working through. Uh I'm planning on talking a lot more about that at my Reactathon talk. Uh next month or in in March. And um yeah, but all those other things, you can implement them in like one line of uh just command, like npx expo adapter, and then it will like install and use Gatsby. And now your web project is using Gatsby, and then the native project is being hosted in the the standard native way. And if at any point like Next or Gatsby or Electron add more support for uh iOS and Android, then it it should integrate very nicely with those as well.
[00:29:22] Michael Chan: That is awesome. That's super cool. I like, I'm excited to see this because I know that there's been this vision for a really long time of, you know, even before React, right? Before React came out and before React Native was was announced and viable, everyone wanted this future that was like write once, run everywhere. And React kind of was like, hey, this isn't actually tenable. Like, so we're gonna kind of like flip it on its head. And it's like, I think they changed it to like learn once, write anywhere. Yeah. But it seems like we're kind of like maybe like getting closer to this, like the original idea, which was to just like write it and it runs on all the platforms. How do you see that future and how do you see Expo kind of playing the role of like actually being that bridge and getting us there?
[00:30:09] Evan Bacon: Yeah, so I I guess I see that future as like the the web has changed a lot in the sense that there we see a lot more of these like web apps pop up, things like uh Spotify or Instagram, Twitter, Um, but I think definitely like Netflix and Spotify are two great examples because they, they don't need to be like indexed, right? You, you just, you just go in and you use the app. Uh, navigation is kind of substandard for like what you would see in like a traditional website where you have like a static header and it scrolls all the way up and you have like a static footer.
[00:30:40] Michael Chan: Oh, sure.
[00:30:41] Evan Bacon: Uh, so I think like we, we still want the ability to build stuff like that where You can have paradigms which make total sense on web and make little to no sense on native, which is why there's all these ways to kind of drop down and incrementally add features. Um, but it would also be very nice to take some of these newer features, these like web app, PWA, native features, uh which kind of haven't really been decided too much in the web and be like, well, why don't we just make those unified? So something like a camera, for instance, which can run in a lot of browsers. Like, why don't we just use this really great spec that native has figured out? Or like permissions and uh notifications is a great one because I think people found out you could have web notifications and they just slap them in in the worst possible way. And- Yeah. I have never met a single person who has ever wanted web notifications turned on. But with native, you turn web notification or you turn notifications on with almost every app that you go into. And I think it's just 'cause like they, they handle permissions very elegantly. They do it at the right time. So having better API, like native API design, stuff like that looks really nice and attractive across web and native. And things like that make perfect sense to share and write once. Then there's stuff like navigation, like I said, where uh navigation is currently just the trickiest topic in universal development because uh it's so different on web to native. Like native navigate- it's not even really called navigation on web, it's called like routing, right? It's called navigation on native. Yeah. Because you've got like these navigators, you know, like the stack where it pushes screens and the tab nav drawer, uh and uh some of those exist on web. But if you were to take like a stack navigator and put it in the browser, it looks really jarring, especially if you like navigate to like a deeply nested screen, because it doesn't- like a native stack navigator has like all the screens like a card, and you push the screens off of the stack. And like with web, if you told someone that you wanted to render all of the pages on top of each other and then just like move between it, it'd be like crazy. So there's a a lot of different like nuance to that that would be really interesting to explore. And I think areas like that uh are areas where we'll probably always have nuance, like uh when it's web you want to do it like this, and when it's native you want to do it like that. But there should still be really great libraries and definitions and guides. And uh I think Expo just defines a lot of this stuff with like uh React Navigation, which is a library that we maintain. Or uh Expo, et cetera, like all all of the cam uh the modules that Expo supports. I always default to camera, but I know I said it like 100 times. Uh uh things like the the video, for instance, a lot of the video paradigms make sense across web and native. In fact, I we see a lot of cool native things show up on web when it comes to videos and uh maps and things of that nature. So uh I I do think that there's just so many little things that you can do in the browser. And a lot of those things overlap. With uh native. And uh Expo is just going to try and maximize getting all of that stuff unified and yeah, all around just be the easiest way to make an app. However you want to make the app, it's just gonna be the easiest way to start an app, build it, and then deploy it to wherever you want it deployed.
[00:33:50] Michael Chan: Well, I really like what you said there about how how the web has a lot of genius behind it. There's some some amazing things that we have figured out like as as a web platform, but at the same time there's, you know, an equal amount of genius, you know, coming from native and that there are a lot of interactions and a lot of things that have been figured out on that side uh that we haven't actually necessarily gotten to yet. So like, you know, camera integration, as you mentioned, you know, video notifications.
[00:34:18] Evan Bacon: Yeah. Or like gestures is a big one.
[00:34:20] Michael Chan: Yeah. All of these things have been figured out on mobile and don't really have solutions. And so when you use these Expo libraries, you actually get to buy into some of those uh patterns and practices that we don't have uh great solutions, if any solutions, for yet.
[00:34:36] Evan Bacon: Right. And vice versa, it would be great to see things like uh maybe different parts of like SSR work with native and uh areas where you like can do indexing. And uh even just like the dev tooling on web is the biggest thing that we take over to native. Like things like the config file is a great example. Like with Expo, you have this app.json config file and that simplifies the iOS info.plist, like a plist file, and on Android the Android, like the manifest.xml, in an XML file. Huh. So simplifying that, we made app.json, and it's like, oh, that's so much better. You're using a JSON instead of a plist and an XML file. But then it's like, after you use it for a while, you, you start to look at web and you're like, well, you can add comments to the the config file, you can have plugins, And they use like a JS config file and uh like if so we're working on like app.config.js now and uh just taking like all of the really great, even just dev tooling, not even like the the standards on the web and just bringing that dev tooling to native is uh making native development just feel so much better and just really fun to use.
[00:35:44] Michael Chan: That's awesome. Now, if someone wanted to get started small and just take one of their components, like let's say something simple, doesn't even have like a lot of interaction around it, something like an app avatar, like a very small little thing. They wanted to use uh Expo for that and um kind of just export this one tiny little component and then use it on all of their platforms. Is that possible? And like what what's the path path forward that you would recommend for that person?
[00:36:09] Evan Bacon: Uh so I think like right now there's still some thought to be done around making it like perfect. It's pretty it's pretty good right now. But I think uh I think like what the the perfect implementation would look like is you can install React Native and then get like maybe just the view or just stylesheet part, uh because obviously if you have 2 or more, now they're reusing stuff. Uh currently, if you uh download React Native Web and you don't use any of it, uh it'll tree shake out all of it. If you use one part of it, it'll tree shake out most of it, right? Uh so if you were to, for instance, yarn yarn add expo-camera and download that, it will expect React Native Web and React DOM to be there, right? And if uh if you use it, then it's just using Vue and stylesheet, so then it will remove everything. It'll remove like text and image and all the other stuff that uh you're not using from React Native Web. So then you have this uh universal camera element, uh which then you can just use in web and you don't need to use anywhere else. Uh I think like we'll see this work a lot better with things like React Native Gesture Handler, which I've been working on, uh because you'll be able to just install it as a gesture library. In fact, actually a great example of this is uh React Spring, because React Spring— uh I don't know if you're familiar with that package.
[00:37:23] Michael Chan: Yeah, yeah.
[00:37:24] Evan Bacon: It's like a super popular web library and it actually uses React Native Animated, like, because that's just a JS animated library. It's like in React Spring when you download it. Yeah. Uh, and people are fine with that. It like, it works very well. Uh, so React Native Web is, it's kind of like that. Like you, you can just install these JS modules and if the native dependency isn't there and you're not running it on native, then there's no problem.
[00:37:48] Michael Chan: Interesting. Interesting. So we're already like, you know, if you're using React Spring, you're already part of this kind of convergence of platforms then.
[00:37:55] Evan Bacon: Yeah, kind of, kind of. I think like they they just like fork the animated part out. It doesn't actually have a dependency, like a proper dependency. But it could in theory. It could.
[00:38:05] Michael Chan: Awesome. So there were a couple questions that came in on Twitter. Um kind of asking about uh what it would look like, you know, so you have this like kind of like Twitter-like style like uh site that you're building with like React Native Web. Um and so you have that. In like mobile, but like how do you actually like expand that out to like take advantage of some, you know, more desktop class type of views?
[00:38:28] Evan Bacon: Yeah, uh, this is a question that we get a lot because I think with Expo right now, a lot of people have native Expo apps and you can just run like- you can hit the W key with Expo start and then it just runs it in the web and immediately it's like, wow, this works in the web. But then you notice like it's the kind of small compact app, unless you made it work for iPad, it's going to be just a small app that's like dragged out and very long. Sure. And uh it's actually easier than than what it might seem to like make that into something that looks really nice on web. The first thing is uh the pseudo-classes, right? Like hover and focus effects. Those are or mostly just hover effects and active effects. Uh these are things that we just see on web and we almost take it for granted. Uh, so there's that library that I made, React Native Webhooks, which just lets you add hover effects and stuff of that nature universally. Then uh media queries is another uh really important thing to have on web, which we usually don't focus on too much on native. Usually what you would do is just look at the the kind of width of maybe an element and you just work on it in the size of that element. So if it's a card, you're like, the card gets to be only this big. You don't really look at like the whole screen size very often on native.
[00:39:39] Michael Chan: Sure.
[00:39:39] Evan Bacon: But on web, that's uh a lot more common. So what we did there is actually really interesting. So I created this library expo/matchmedia, and what that does is you import that, it's a side effect, and it polyfills out native so you can use a web library on native. So you can use React Responsive, which is a really popular JS uh React media query library. And uh we actually kind of went the other way and we made native work more like web, so you can implement universal uh media queries using this package, React Responsive. And uh it's awesome. So I would recommend media queries and pseudo classes and then just like making sure that your navigation looks and feels right. Uh which is it's got so much nuance to it right now. That's like the one thing I'm working on very act like as soon as we're done with this call, I'm going right back to navigation work.
[00:40:28] Michael Chan: Awesome. Now I think we have like kind of like one last kind of branch of questioning that people um asked on Twitter. And this is about testing. Um I know that it can be difficult enough to just test a component or a tree of components, um, you know, given the tooling that's already there. What does that look like when you're testing across, you know, 3, 4, 5, 6 platforms?
[00:40:52] Evan Bacon: Yeah, uh, testing was a weird one when I started with this project. And what I found was- so React Native actually, it has a Jest preset built into it, uh, the React Native Jest preset, very aptly named. And when you run that to make like unit tests, just unit tests, uh it's going to mock out the platform as iOS. So that means it will take the the library platform from React Native and it will make it uh act as if it was running on iOS. So if you did Platform.OS, it will equal iOS. And when we talked about earlier those uh platform extensions, like if there was a file app.ios.tsx, that would get used in the unit test when it's resolving things. So even in React Native, I found it wasn't testing your Android code. It was just testing how it works on iOS. So this was a big problem because I was pushing code, like tons of new modules, and then- Yeah. People would like make an update on iOS and it would break web because there's so many differences. And so uh I had to like really rethink this. And so I I I worked on this thing, it's called uh Jest Expo, but uh it's just, it's uh universal testing with Jest. And what it does is it mocks out the platform 4 different times, so one for iOS, Android, web, and then Node, so you can test your SSR modules. So it it uses something called a uh a Jest multi-runner, and with that Jest multi-runner, it will mock it out differently for each platform. And then you can press something like the X key and then enable or disable like iOS, Android, like whatever you want to work on, which is uh it's really nice. And then for the tests, it actually does like the inverse of that, where you can uh have a test which is called like test or like like app-test.web.tsx, and then that will only run with the web resolution. It won't run on iOS or Android.
[00:42:37] Michael Chan: Interesting.
[00:42:38] Evan Bacon: Yeah, so right into even like the test integration, there is platform resolution, like universal stuff built through it. Because something we found was like with React Native Web, it was very well thought out for sharing things like view and image and text But what about like when you want to share your Babel or your webpack config or your Jest config? Uh these things are like not very clear like how you're going to implement them because you usually have like one file called like the babel.config in the root file of your project. And so it's hard to switch. But so we kind of needed to think through all these and Jest was a big one. And uh so then kind of pushed it further than there. We made a library called uh Jest Expo Enzyme, which lets you run like universal Enzyme, so it'll mock it out for native or um web if you're running on web. And Enzyme lets you do like uh the tree tree testing, like render testing. And uh then there's another library that I made called Jest Expo Puppeteer, which as as the name implies- Oh, cool. It lets you run Puppeteer right out of the box with uh an Expo web project. So you can do like headless end-to-end testing in a Chromium browser. Uh, just without having to do anything. Uh, I'm, I'm a very, I don't know if paranoid developer is the right way to put it, but I, I, I love my tests. I, I like to make sure everything's tested.
[00:43:55] Michael Chan: Well, I feel like once you've worked with a comprehensive test suite and it's caught things that you would not have thought about coming back to a project, it's like, it feels invaluable. You feel like, so like you're like on a high wire without a net, like when you don't have one.
[00:44:08] Evan Bacon: Yeah. I think people feel this on a much broader term when they use like TypeScript. And it catches like some- yeah, and they're just like, I'm never gonna not use you again. That's how it feels with tests sometimes. I'm just like, yeah, I need these for everything.
[00:44:20] Michael Chan: Totally. Well, thank you so much for your time. We're like right at the end of our time. And you've given us such a wealth of information about uh what you're working on. I am so excited for your talk in March. Uh that's gonna be at Reactathon. And I'm hoping to be there. And it's gonna be awesome. If people want to learn more about Expo, what you're doing uh in in React Native and all of those really related projects, uh how do they get connected? And then also, how do they find you?
[00:44:47] Evan Bacon: Uh so if you want to follow Expo, you can follow us on Twitter at uh @Expo. Uh it's a good Twitter handle. Uh it's just E-X-P-O. And then uh if you want to follow me, I'm @baconbrix, B-R-I-X, or I'm online at evanbacon.dev or baconbrix.com. Those are all Expo web websites. So uh you'll be using Expo there as well. And uh yeah, I'm just generally on GitHub all the time. So if you open an issue on any any repo, I'll probably respond to it.
[00:45:16] Michael Chan: Awesome. Well, Evan, it has been a pleasure to have you. Thank you so much for uh telling us, you know, what we can look forward to in the future.
[00:45:22] Evan Bacon: Yes, it's been great uh talking with you today. Thanks so much.
[00:45:26] Michael Chan: For links and show notes, visit reactpodcast.com/81. 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 reactpodcast.com. This episode was edited by Mikael Delport. It was produced by Mikael Delport and Sarah Jackson at Speck, 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.
chantastic.fm