chantastic.fm

92: Chance Strickland on Reach UI and Building Composable Open Source

Episode 92 · April 30, 2020 · 00:48:32

Hosted by chantastic · With Chance Strickland

Sponsored by Infinite Red

Download MP3 · Jump to transcript

Chance Strickland (@chancethedev) and chantastic talk about Reach UI and building flexible libraries for the web.

They talk about separation of logic with statecharts, the cascading complexity of accessibility, unopinionated approaches to styling, and the career effects of great open source.

Featuring

Links

Related episodes

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 on React Podcast, we sit down with Chance Strickland, better known as Chance the Dev, to talk about Reach UI and building flexible, composable, open source libraries. We tackle the topics of accessibility, state charts, TypeScript, unopinionated styling, library packaging, and the career effects of great Before we dive in, I want to tell you about today's sponsor, Infinite Red. If you're building a React or React Native app and you're feeling stuck, check out Infinite Red. They'll come alongside you and get you back into a groove with your React or React Native project. They've taught tens of thousands of developers through open source and their annual React Native conference, Chain React. Start or refer a new project today and get 2 free tickets to Chain React Conf in 2021. Get started at reactreactred.com. Podcast.infinite.red and build a beautiful, functional app today. Chance Strickland, welcome to React Podcast.

[00:01:14] Chance Strickland: Thanks, man. Thanks for having me.

[00:01:16] Michael Chan: It's good to have you. Um, you moved to my town. You called me up. We got coffee one time. I was ridiculously late. I still feel bad about that. I'm sorry.

[00:01:25] Chance Strickland: It's okay.

[00:01:27] Michael Chan: Um, but how are you liking San Diego?

[00:01:29] Chance Strickland: I love it here, man. It's— uh, it's It's such a great town. I I just, for the listeners, I moved from Nashville, Tennessee. I'm originally from Atlanta, Georgia. And so this is my first time not living in the South. Um and I, you know, have a have still have a soft spot for the South and uh miss the comfort food from time to time. But San Diego is, it's always sort of like, ever since I first visited here, I I felt like some like magnetic attraction to this town. Like it's so, like the speed, the pace, the uh the culture, the vibe, the weather. Just the- you're so close to anything in the outdoors that you might want to do at all times. And it's just- and it's always nice enough to do whatever you want to do outside. So it's just- I don't know, it's great. And I, I love it. Yeah, having a great time.

[00:02:16] Michael Chan: It's pretty great too, because like, you know, if you- let's say you don't want perfect weather just for a hot second, you're only about like an hour- you're only about an hour and a half from like the desert or the mountains or like whatever you want.

[00:02:28] Chance Strickland: I never understand, everyone's like, Oh, don't you miss seasons? I'm like, the seasons are really close. I just go somewhere else that has them. And, and the good seasons are only 2 weeks long anyway in the South. Like, fall is amazing. I love fall, but it's over in 2 weeks. You go from like, yeah, disgusting summer to like sort of fall to like, nope, we we joked on you, like it's actually still summer, to like sort of fall, but also like rainy all the time, to now it's just freezing. And so like, who wants that sort of like tumultuous day-to-day. Like I I just like waking up in the morning, going outside in like a light sweatshirt and walking my dog. And that's what you do here.

[00:03:04] Michael Chan: Now you mentioned the pace, like what is it? I I've my whole life have have lived here. So I'm kind of curious, like, you know, coming from from Nashville, like what is the uh what's the pace or like Tennessee? Sorry.

[00:03:15] Chance Strickland: Yeah. So so Nashville's actually from a just a cultural, like business pace kind of perspective. It's not that different. I actually really liked living in Nashville a lot as well. For that reason. But what I really like- so I like to compare it more to like New York or LA, uh LA specifically, because they're both Southern California. Um, but in LA, there's always like- everyone's always moving. And um, when you interact with folks who are especially like entrepreneur kind of like situations, meetups, and um, different sort of like networking events and everything, when you encounter people in in the business space especially People are always like ready to move on, like they're in a hurry, they want to like get somewhere, they want to- they want to, you know, a nice like wrapped up conclusion to every discussion. They want- they want everything to be like positioned to- to move you into a certain destination, whereas I feel like here you can just sort of go to a networking, which is exactly what I did, by the way. Shortly after I moved here, you know, I connected with you, I connected with Michael Jackson, like some of the folks I knew who who lived in the area, um just from from online. Uh but I also started going to these meetups. I was freelancing at the time, so I would go to these freelancer meetups, these entrepreneur meetups, and people were just like having conversations like normal people, you know. And it's it's it's sort of like the difference between LinkedIn and Twitter, you know. Like LinkedIn feels like this really stuffy place where everyone has a motive, whereas Twitter, people are just being humans, right? Like I I think- Interesting. San Diego is Twitter. And LA is LinkedIn, you know, but like it's a cooler LinkedIn than maybe, I don't know, you know, New York or Singapore or something. I don't know, it's just like, it's not as stuffy in LA, but it still sort of like has that- I don't know, I don't know how to describe it other than that. But-

[00:04:58] Michael Chan: Yeah, people are chasing some kind of outcome maybe instead of just being in the moment.

[00:05:02] Chance Strickland: Yeah, and I think people here are just, no matter what their, their end goal is, they're still happy to like connect. It's very similar to the South in a lot of ways.

[00:05:10] Michael Chan: Yeah, I love that. So, you're awesome. And one of the reasons that I wanted to have you on the show is because you maintain one of my- well, build and maintain one of my favorite uh React projects. And I kind of wanted to just discuss with you Reach UI as, I guess, like a lens into what it takes to build a, I guess, flexible and competent uh React UI library. Um, and I know that, you know, Reach is like fairly focused um you know on on accessibility. But I think that it gives us a lot— like a a really good lens into kind of modern requirements for like a flexible UI tool. Um but first, before all that, uh just tell me a little bit about Reach. Like what the goal is. Like what you've been working on the last you know year or so.

[00:05:58] Chance Strickland: Yeah. So, Reach UI, for anyone who's not familiar with it, is uh it's a component library. It's been around for a few years. It was um initially created by Ryan Florence. And um you know it's sort of at simplest level, there's it gets actually Ryan wrote up this really great philosophy document on Reach UI that I think does a really great job of explaining this in detail. But at a very high level, um the 3 pillars that I think of um when I think of Reach, I think of accessibility, uh having useful abstractions, and composition. Um those are sort of the 3 guiding principles that I think of when I'm building a new Reach component or when I'm considering making any sort of feature additions to to Reach UI. It's important to note, too, that unlike a lot of other component libraries, Reach UI is intentionally low-level in terms of uh opinions about presentation style. Uh we don't do very much at all to style any of our components because the idea behind Reach is that we are providing you a a foundational uh set of elements to create design systems with. And you might have any number of ways that you approach styling in your design system. And we don't want to interfere with that. We want to work seamlessly with that. So, if you style components, great. You style components. If you use CSS, use CSS. If you want to use Sass modules, use Sass modules. It doesn't really matter to us. Um, we give you enough to make our components um usable by default. And then you even have the ability to opt out of that or but just not import our CSS and nothing happens. And you know, you can do whatever you want with it. But But yeah, that that being unopinionated about style and presentation, um plus those 3 pillars of accessibility, having useful abstractions and composition, I think are ultimately what um Reach boils down to in in terms of our approach.

[00:07:47] Michael Chan: Yeah, I love that. Now, I think what is the— like what is it that like kind of sets uh Reach apart? Like if I'm not mistaken, Reach has kind of been around for maybe 2-ish years now in some form?

[00:07:59] Chance Strickland: Yeah. And I would say that Reach, um, when it first was released, it was- Ryan has this really amazing gift for seeing things down the road that I think a lot of other folks don't necessarily see coming. Um, it's it's really awesome to just have the opportunity to sit and listen to him think. Um, he will just think out loud uh in in a call from time to time, and it's like, ah, I- you were like 10 steps ahead of where I was in terms of whatever the conversation is, right? And so, like, being able to work with him on Reach was awesome because you get to experience that firsthand and learn a lot from that. But I like to imagine where his head was when Reach started was sort of different from where it is today because so many existing component libraries have adopted a lot of our approaches in Reach. You know, ever since it came out, it has- it's been a model there for others to to grab at and sort of take inspiration from when they're building their own component libraries. So, I would say like what set Reach apart- sets Reach apart today is different than what set Reach apart when it first was released. And when he started building his initial components for Reach. Um, and where Reach will be in the next year, 2 years, 3 years, I mean, how it stands apart then, I think, is uh yet to be determined. Because we have to see where, you know, where the community takes us. But at this point in time, I think Reach is still different because we don't give you anything in terms of uh in terms of presentation, uh whereas a lot of libraries have they have some opinions about how you go about doing things, right? Like um and that's not always a bad thing. It just sort of depends on what your need is. If you're developing a design system from scratch, you want a sort of more bare-bones thing that you can, you know, throw your whimsy at, right? But if you want to build a product very quickly um and get it to market and you don't have the the time and energy to go and style everything, then maybe another library is better suited for those those tasks. We're not trying to be that kind of library, you know?

[00:09:54] Michael Chan: I love I love throw your whimsy.

[00:09:58] Chance Strickland: I'll market that.

[00:09:59] Michael Chan: That's good stuff.

[00:10:00] Chance Strickland: Uh one one other thing uh before I forget about it um that I do think sets us apart, aside from just presentational differences, is um is our approach to to managing state. We we give folks the option to to manage state themselves, just like a controlled and uncontrolled input in React, right? Like you have the option to to let the browser handle it or you you can go and handle it yourself. Um, you know, we have a similar approach to most of our components. But, you know, we do a lot of work behind the scenes to make sure those interactions are seamless. Um, and and one of the things that we've adopted uh relatively relatively recently is state charts. And specifically using uh the XState FSM library uh that uh David Khourshid developed and built. Um it's a you know great library, but more important than the library is the just this whole like idea of thinking in state charts. And just adopting that model for state management in the library has exposed so many nuances for for all of these components. Um the most recent one on my mind is the one that I most recently built. It's it's the list box or what we think of as a custom select dropdown, right? Like, there's so much that if you look at the way an operating system handles that component, there's so much that it does that you don't really think about. And there's so much nuance in like every single interaction. And it's different from every browser to browser. Yeah. And it's different from one operating system to another. And every browser or device within those operating systems even treats them differently. So, um, trying to capture all of that nuance would have, I think, been impossible to do. Without adopting statecharts and also introducing a ton of bugs. Um, I think that's truly been uh one of the most helpful things that we've done in our library to to reduce bugs and and to catch edge cases is using statecharts.

[00:11:48] Michael Chan: Interesting. Now, so, there's so much there that I want to cover. And so, I think we're just gonna have to kind of like go down the list and cover it all. Um, but I think 3 things in particular is like like what you mentioned about styles. Um, just being unique in not having a strong opinion about styles. You know, we see a lot of like kind of of uh all-in libraries where it's, you know, the the the opinions are baked in. And so, you're just kind of like taking it, using them as is, maybe tweaking them a little bit. Um but but largely borrowing someone else's kind of strongly held opinions. And then kind of the the notion that like the core building block of this library is XState and— or uh sorry, state machines and state charts.

[00:12:34] Chance Strickland: It's a lot of vocabulary, I know.

[00:12:36] Michael Chan: So much vocabulary.

[00:12:37] Chance Strickland: Honestly, when we adopted state charts, that was the biggest struggle for me, was getting all the words right. So many.

[00:12:43] Michael Chan: We should probably cover that then, too. Because if you understand it, then we should make sure that everyone else does, too. And then uh and then finally, just kind of like the organization of the project, which which also feels kind of um uh empowering. Like you know, you can just kind of take what you need and and and whatnot. So, I think the first thing is is the styling. Something that I'm super fascinated by is just this- having to had to like migrate a lot of our like legacy systems to kind of more modern systems in React. I have this little like fear constantly that like the things that we're making now will not stand the test of time.

[00:13:23] Chance Strickland: Sure.

[00:13:24] Michael Chan: And so, the Reach stands out to me as a very fascinating project because it has found the boundaries to not be super opinionated about style and to make uh make the actual like state transitions and all that stuff um transcend React itself. Um so, with with the styling, tell me a little bit about kind of like where that boundary is for the majority of the components. Like what you do export and like how you can kind of the options for customizing it?

[00:13:54] Chance Strickland: Sure. So, out of the box, we just write some very basic CSS for all of our components. Um, and when I say basic CSS, I mean we write enough so that the component functions on screen without any changes. So, um, when you fire up our Storybook instance, you are going to see all of our components, um, show up and they're gonna work. And we don't add any additional styles, uh, in our testing uh sandbox to to make those work. Um but we also don't make them pretty, you know, it's like the browser's defaults, the user agent settings. Sure. We're basically trying to imagine what user agent would do if we were user agent. And we say, hey, here's this thing. Go do with it. And we also don't want it to to make it too hard to override what we do give you. Um so, you know, like a button. If you have a default browser button, and you want to make it look like not a browser button, you have to go and override all of these settings in every- to make sure every browser sort of like cancels out what it's doing by default with a button. Um and so so we're like, we try to be user agent but like less heavy-handed, right? So we we just literally try to make it work and the rest is up to you. You know, you can you can even get rid of our styles completely. Just don't import our style sheets and you don't have anything. And then it's up to you to go in and just do everything from scratch. But that's totally fine. So, if you want to build a styled component out of out of our components, you just make it a styled component and do whatever you want with it.

[00:15:21] Michael Chan: It's an interesting challenge because, you know, because these elements are interactive by default, uh you do have to provide something or else like the documentation would be inscrutable, I imagine. You know, with like dialogs and accordions and all these kind of things, they would just- everything would be shown or not shown all the time.

[00:15:40] Chance Strickland: Yeah, and the the general approach there is if we do have to give you anything, we just make sure that you can override it if you need to. So, even if we're doing, um, say, inline styles for something, which is, um, you know, we may do for positioning certain elements on the screen, we will make sure that we are inlining our styles before whatever you would attach to the component, um, would be spread into our style prop, right? So, we want to make sure that you have the ability to go in and override our defaults. In most cases. There are some things that obviously you shouldn't override because they're key to maintaining like accessibility or something. And we don't want people to go in and make their components inaccessible because that defeats the purpose of what we're building, right? But even accessibility props like the ARIA attributes and and roles and tabindexes and those sort of things that we that we have to take into consideration. Um, even when you follow the ARIA guidelines, we can't predict the context in which our components are going to exist. So, just because someone adopts um like a menu button, for example, they might put a menu button in, say, the corner of a tab, right? So, you've got like a a this set of tabs and then in the corner of each of the tabs, there's a nested menu button. So, one of the great things about Reach UI being highly composable is that you can do that fairly easily. Um, it's really fairly simple to integrate all of our components with one another and create these really beautiful, complex user interfaces. Um, but the the caveat there is that some of those accessibility defaults need to be updated to reflect the context in which you are putting something on the screen. So um, so even though we apply a lot of, you know, accessibility props under the hood, you can't just grab something and go, "Oh, it's accessible," right? You still need to do your own testing. And depending on the context that these things are built in, you need to make sure that you are doing some other things to supplement what we're doing and and override what we're doing in the event that you're using them in a totally you know, weird context that we haven't predicted. So, um, labeling is another huge thing that I think folks often miss. Even when they're working in um just any sort of HTML uh or templating environment, you still have to label things. And and we have no idea what the label of your menu button is. So, you have to tell us. So, we we can't do everything. But we want to make sure that we're doing enough. And and whatever we do, we need to give you the ability to be smarter than us because you know the context of what you're building better than we do. So, we need to give you the ability to go in and override what we're doing fairly simply if you need to. And the same thing goes with styles.

[00:18:12] Michael Chan: Yeah. So, one thing that I've really liked in using Reach, um, especially with like the styles, is is that you provide these— um, you use data attribute selectors for all the CSS. Which is not like super common like across the industry. But something that I am actually a really big fan of. Especially kind of having to work between like uh like daily work between, you know, React and non-React systems, the copy-paste ability of like data attributes into elements, like totally far- is way superior to like CSS classes because like of freaking className in-

[00:18:53] Chance Strickland: It's like bringing back the ghosts of uh of jQuery now where it's like addClass, removeClass. And you end up with like you've got all of these things that are all trying to do their own thing and they're all just going by class names and then you have like 30 class names that might conflict with one another. Yeah, it's it it can be madness if you try to do everything with a with a class name, right? Um, but also, like, you might have your own- again, this goes back to the design system. Uh, if you're trying to build your design system and you are using CSS in your design system, you have all of your own class names. We're not gonna jumble it up with ours, you know? Like, if you don't want to use data attributes, then don't use them. You don't have to. Um, but, you know, they're there for us because They're all prepended with data-reach so that they're specific to— you know, you know this is a reach data attribute, right? And so, like, if you want to change it, it's just change it. You know, like, you don't have to worry about removing our class names programmatically and then adding your own class names. It's just it's just less chaos, honestly. And um, you know, speaking of state charts and all of this, uh David Khourshid gave a really great talk at uh .CSS in Paris um last year. And it was about adopting the state machine mentality for CSS, which I thought was incredible. And the way that he approaches this is using data attributes. Um, when you have this whole concept- we won't get too deep into state charts because I could talk about that all day, too, if if we had the time. But one of the things I love about just this concept of of the finite state machine is that there are a finite number of states that any UI component can be in at any given time. And if you think about it, data attributes are perfect for implementing this in CSS. If you have class names, let's say you have a button. This is a classic example. You have a button and you have like 3 button variants, right? And you have class button, class button-primary, but then class button-secondary. Well, what if you have class button-primary and class button-secondary applied to your button at the same time? That's not possible, right? Like you can't have a- unless you're you know, you adopt some weird thing where your colors just meld and you get some like weird, you know, it's like a paintbrush and you've just mixed the two colors. That would be kind of cool, actually. That'd be sweet, actually.

[00:21:00] Michael Chan: I'm thinking about it.

[00:21:01] Chance Strickland: Somebody needs to build that. That'd be pretty pretty sweet. But nonetheless, in in the real world where um specificity and order in your style sheets is going to to take precedence there, who knows what you end up with, right? And especially in a component system where you might have your CSS being injected in various orders, you know, like That's an impossible state. So, if you use data attributes, you could say data-color equals an enum of like 10 colors. But you can never have multiple colors, right? So, like the idea of using data attributes to prevent impossible states for components is also kind of cool, I think.

[00:21:32] Michael Chan: Oh, yeah. Absolutely. I've been kind of doing- taking that approach more and more just in my own work. And I love it. Because I think it also- it tokenizes like the right part of it. Right. Like it tokenizes the enumerable as opposed to like the whole thing. Right. And I, I really love that because then you don't have to do all these like just wild, you know, like BEM style things that nobody can remember all the rules for anyway. It just, it takes, it's such a cool way to write, write styling, I think.

[00:22:01] Chance Strickland: Another really cool benefit I think is when you, so when I, everyone has their own workflow, but when I'm writing a component, I like to, to write the markup first. I don't even think about state or I don't worry about state or managing state or changing state or, or user interactions right away. I think about the markup. And so, when I'm scaffolding out a new Reach component, I'm writing all of the markup and I'm also writing the data attributes. But then when I'm thinking about what data attributes we're going to use, that helps me very seamlessly transition to thinking about state. Because you have to think about state to think about which data attributes you're going to use. And then once you write those, it's sort of quick to actually write out all of the state logic because you've got the number of states right there in front of you. You've just written them out in the markup. So, it's also a cool side benefit, I think.

[00:22:46] Michael Chan: Yeah, yeah, absolutely. So, let's transition into talking about the statecharts portion of it. Because I think this is really interesting to the, you know, the the programmers who are listening right now. There's a tendency, like if you're, you know, you're writing a React library, to just double down on React. All of the features that are in React for managing state and whatnot. But you've gone like a different direction. Uh, which is to do a lot of the logical parts in statecharts and then have just use kind of React as the rendering portion of that. Tell me a little bit about the the thinking behind that and and what you've seen as like uh the benefits of that.

[00:23:26] Chance Strickland: Yeah. So, I'm really excited about this. And let me just go ahead and say, too, that I'm pretty new to thinking in statecharts. Um, I've like totally bought it and drank the Kool-Aid. Like I'm in there. And I love statecharts and I love finite state machines and just the whole the whole thing that all of the benefits that come with it I think are are so tremendous. At least for what I'm building, right? For these UI components, I think it makes so much sense. But I am still new to it. So, I'm still learning a lot as I go. And I'm still consulting. I I I feel like I'm consulting people all the time. It's like, hey, am I actually doing this right? Like there's certain- Yeah. Like it's such an old concept, right? And um when you hear people talk about it, one of the things they'll say is it's like this old battle-tested thing. Uh this idea of finite state machines. And it's it gets super in the weeds and very computer science-y. Um and I am not a computer science person. I don't have a degree. Oh, same. And I I literally don't even know how I do my job most days. So, the fact that I'm I'm doing this actually sort of amazes me sometimes. But um but at least understanding the basic concepts of of the finite state machines, I think has made a a tremendous benefit to uh to how we build our components and how we think about state in Reach. And I keep mentioning David, right? Like he built XState. Uh, we use XState. David is also a contractor uh with ReachUI or with uh React Training, um the company behind ReachUI. And so, we we were working together already um on various projects and and he would be in our Slack and we're always talking and communicating. So, if you know David or even if you just follow him on Twitter, like that guy will not stop talking about finite state machines. Um, like it's literally synonymous with his name at this point. Like the like if you. Type- if I were to go on Twitter right now and type anything about finite state machines, David is going to comment within probably 10 minutes or so. Very tenacious. I think he's got alerts set up, you know, to go off when someone tweets about finite state machines. So, he's always banging this drum. And so, if you work with him, at some point, you're going to try using finite state machines for whatever it is you're building. Um, and and we did. And it was just like like I said, it was one of those things where as soon as you do it and you start Like, the first- I will say the first time you do it, you're like, what the heck is going on here? Like, there's- the initial gut reaction is you're writing so much more code and you don't really understand why. Yeah. Right? Like, if you write a state chart, like, it's it's very structured and detailed and and it's it can be a lot. Um, but then once you start running- the biggest thing for me, the the moment that like really sold it for me I was working on the list box because that was the first one that that I wrote a finite state machine for uh from scratch. And I was working on the list box. And it's just when you run into some of these edge cases, you start thinking about like all of the hoops you have to jump through if you're just writing like very um imperative JavaScript code to have to deal with some of these edge cases.

[00:26:25] Michael Chan: Because it's gonna be like a lot of complex like if-else.

[00:26:28] Chance Strickland: Yeah. Yeah, complex if-else arrangements. You have to go and like create these refs to track like certain interactions. And like if this interaction took place before this interaction, then we're gonna do this. But if we're not, we're just gonna do that, right? But like those are the sort of situations where state charts really shine. And um when you're building it out initially, there is that initial um overhead of like, oh, this is so much and I have to think about all of these different things. But then once you start running into the edge cases, it's like fixing those problems is so much simpler. You've already got your different states set up. Interesting. And it's just a matter of setting like a condition, um or uh or setting up some sort of action function in your state chart that um that checks to see if a certain thing um happens in a certain order, right? Like those sort of um fine-tuned pieces of logic become more apparent and easy to write once you already have the state chart built out. So, I find working in them from the start has benefits that reveal themselves later on. It's actually a lot like writing in TypeScript, I think. Which we also do. And I- when I first started learning TypeScript, it's like, what is this thing and why why am I dealing with it? Like, why is it necessary? It's just yelling at me all the time. I don't want that. I just want to build stuff and make it work. But this thing just won't stop yelling at me. And I can't decipher any of its yells. So. What am I doing? But then when you have to refactor like a hefty application and now you have type safety, it's like, oh, I get it, right? It's the same idea with statecharts, I think.

[00:27:56] Michael Chan: It's a reduction in your your uh initial coding velocity. But like the long-term maintainability of this thing, uh it when you have those bugs— or this is what I'm understanding— is that that when you have those bugs creep up that you didn't anticipate when you first wrote the component, there's a place for that instead of just being like, oh, I guess I got to do another nested conditional uh and like consider all the timing aspects of what could or could not have already happened to make this decision.

[00:28:23] Chance Strickland: Yeah, exactly.

[00:28:24] Michael Chan: So, I think I'm I'm definitely not like a state charts uh expert by any means. I have a very like shallow understanding of it.

[00:28:31] Chance Strickland: Oh, neither am I.

[00:28:32] Michael Chan: But I wanted to kind of clarify something with you. Like the way that I think about them, at least right now, is that you know, you have useReducer and that kind of allows you to define, you know, events or like actions or whatever and kind of the the resulting state of those things. And that statecharts is kind of an additional layer on top of that. You know, so you have you have let's say like useState, which allows you to just change the state directly. useReducer gives you the language of like events. So like play, pause, stop. Sure. Right? And allows you to change multiple states. Where finite state machines and state charts come in is at the next level where that actually defines the lines between those states and like how like what can transition to what, what is disallowed, etc. Is that an alright way to think about it?

[00:29:24] Chance Strickland: For the most part, I think so. And I think so you can sort of simplify it by uh introducing like a micro-step, right? Like First of all, uh I think it's important for people to realize you don't need a library to write in statecharts. Um you you can write your own transition functions, um which we actually did. Like I didn't personally do it, but Ryan had written a few in other Reach components before I came on. And he was just using like a much simpler, scaled-down version of this idea of transitioning between one uh from one state to another. But um the way that I started thinking in statecharts, or at least in finite states, was just by using reducers. You don't need really any other additional help or functions. So, think of your average uh model for a reducer in React or using Redux or whatever whatever state management solution you're used to if you're writing reducers. Um the typical model is you have a switch statement to catch the action type. And depending on the action type, uh you do something. You change state. You you make some some sort of adjustments, right? You like you respond to an action. Um, which in state chart world, um, or at least in in XState, they call events, but it's the same idea, right? You're sending a message somewhere and that message has some, some data attached to it. It might respond a certain way if the message reads one way and it'll respond another way if the message reads another way, right? That's the core idea is it's just a message with some data and then your reducer decides what to do with it. So if you write a reducer with this switch statement that just says, based on what action you send me, I'm gonna do this thing. Let's say you have 2 switch statements now. And you have a switch statement above that first checks what is the the current state. So, and when I say state, I mean, let's like a specific- like you have a limited number of strings, let's say. And that is that's your state. So, in XState, um, the state is this enum where you've got- you're only in one state. And then you have additional data that XState calls context. React sort of conflates the two. It has this like state object, right? And when you're working in with a reducer, you've got your state, your your dispatch. Um, if you want to think in finite states in a very simple way and you're used to working in reducers, you can just rename some of your variables and start thinking in finite states. You can think in- instead of calling it state, you can just call it contextual data or state data or- Got it. Okay. Just like have your state data be something different from state. And think of state as a as a property on your state data, which is just this enumerated string value. Um and think of your UI existing in one state at a time. Now, in your reducer, instead of just having a switch statement for your action types, you also have a switch statement above that that's checking what your current state is. So, think of a traffic light. If a traffic light is red, it can only go from red to green. It can't go from red directly to yellow.

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

[00:32:24] Chance Strickland: So, if your current state is red, in that switch statement, you will you will check for an action that will send it to green, but there is no action that will send it to yellow. So, if your reducer receives an action that would otherwise send it to yellow, it's now caught by that initial switch statement. That is an illegal state transition. Um, and it just If that were the case, then you would just return whatever your previous state was and and do nothing. Um, so, now you've got like two guards. Your one guard is saying what state are you coming from? And then the next guard intercepts the action that then tells it what to do. And if there's nothing there, then it just shoots you out at the end of the reducer and doesn't do anything, right? So, like- Nothing to see here. Nothing to see. So, um, you can't have impossible states now because you can't move from a red to a green light. You can't go from a- You know, a green directly to a red either. So, you have that yellow light that can only be accessed from from green, right? Like green, yellow, or if the power shuts down and now you need to flash yellow, right? Like so, you've got— um you can set up all of these uh these edge cases in in a state chart. Um and now in your in your uh you know your handlers, your event handlers, you just pass actions. You don't do any conditional checks. You're not like, oh, like when a user mouses down, I need to check, did their mouse move first? Or I need to check like Which thing did they click on? Like, you just send that in the in the dispatch. You just send that as data and then the state machine handles all of that. Or in this case, a reducer, right? You can do all of this with just a reducer. You don't need anything else really. Reducers are still great. We still use them. Um, that's how we pass messages. That's how we write our like our interfaces that talk to the state machine is we just send off something in a reducer. So, uh, we still use React to manage state. We just have state charts to sort of define the logic of our state.

[00:34:12] Michael Chan: I love that. I love that. I think that's a really interesting like point to make too, is is that it's not- you're gonna be writing this code eventually. And it sounds like what what state charts offer you is just a structure that kind of gives you some like a way to discuss these things when they need to be loaded back into your brain again, like your human brain again. Um that isn't like if something and something else and another thing that are kind of seem unrelated, do this thing.

[00:34:42] Chance Strickland: Yeah. It's it's really like everyone talks about separation of concerns and, you know, everyone has their own meaning for that, right? But like really, when I think of the the value of that that way of thinking, I think of like separation of related logic. And so, yeah. Um, and again, you can do this without a state chart. You can write a reducer function that— and you can write all of your state in a way where you group this um related logic together. That's what hooks are so great at, right? Like hooks are amazing. And it's addition to the API that allows you to sort of write in related logic versus like when did the thing mount or do a certain thing, right? Like it's you can yeah you can now think in related logic. Statecharts provide a very similar benefit in my mind. Um where you don't have— like again, you just send a message and the statechart deciphers that. And if it's not related to, you know, that particular event, then it just spits you out in the other end and says, yep. Just continue doing what you're doing.

[00:35:37] Michael Chan: So, we're kind of like getting a little bit late in here for me to be asking new questions. But um I want to kind of talk real quick about the the actual structure of Reach. And I think that, you know, it's become more and more popular to have a like an npm organization and have like little small packages. And that's the way that Reach is structured. So, you can just get like the menu button. I'm kind of curious, um in a from a tooling perspective, What are you using to manage that repository with a bunch of packages under one organization?

[00:36:07] Chance Strickland: Yeah, I'm- I hate tooling. So, like, I'm the- I don't know if I'm the best or worst person to ask this question, but I try to use the tools that let me do what I actually want to do, which is just build components. So, like, um, thankfully, we exist in a time where there are a plethora of really great tools out there. We use Lerna. Uh, since it's a monorepo, we we use Lerna to sort of manage our uh our launch and dependencies. And upgrading and that sort of thing. It's pretty painless. We have some scripts written that just sort of help us not think about that kind of thing.

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

[00:36:39] Chance Strickland: There's some trade-offs. Like I I haven't really figured out- and I know that there are answers to these questions and I'm I'm sure some of your listeners will be able to to share those. But um you know I I haven't quite yet figured out once we get to a 1.0, we've sort of decided- right now, all of the different packages are coupled together in their versioning. And there's not really this um the idea of semver is not there, right? Like we're not- we're just releasing things. So, like if we have a batch and there's like one breaking change in in one component, like all of the components get updated with it.

[00:37:09] Michael Chan: Gotcha.

[00:37:10] Chance Strickland: And I haven't quite figured out what the workflow is. Once we get to a 1.0, I think we'll change our approach there. Um, but, you know, we'll get there when we get there. We'll figure it out. But Learn is still a pretty powerful tool for that sort of thing. We're using TypeScript. Which adds a ton of complexity to the build process and for all of the tooling. Um, thankfully, Jared Palmer wrote a really amazing tool called tsdx, which is just a lifesaver if you're starting any new um TypeScript open source package uh project. Then tsdx is is tremendous because it handles all of the integrations with uh TypeScript and Jest and Babel and Webpack. And you don't have to think about that. And I hate thinking about those things. So, um. It's really, really helpful. I did use tsdx initially when we when we moved from uh JavaScript to TypeScript. Um and then once we needed a couple of customizations, I basically— um it doesn't have like a create React app eject feature, but I sort of did that on my own. I just went and like pulled out all the guts and and rewrote what I needed to. But not enough to where I have to think about it very much because I I don't want to have to waste my time doing those sort of things. But Um, those are the two tools that I think we relied on the most.

[00:38:21] Michael Chan: Nice. Nice. Now, when talking about open source and the, like, the benefits of like a modern open source project, it's hard to separate like successful open source from, I guess, like going back to the LinkedIn part of our conversation from like kind of being a calling card or like a resume item or whatnot. And I know that just recently, um, you know, unfortunately, uh, React Training had to break up. And you were looking for new opportunities. Um, how did your work, um, kind of influence that job search? Like your your work on this, like, you know, pretty high-profile project.

[00:38:56] Chance Strickland: It was invaluable, honestly. Like, you know, everyone has their own story. Everyone has, um, you know, their own boundaries and what they're able to dedicate their their free time to. Um, and I don't want to, like, disrespect anyone's decision, but honestly, for me, Like committing, even if that were a free project, like if I didn't get paid to work on it, let's say, and I just decided, hey, I'm going to to be a maintainer of this project and I'm gonna reach out to Ryan. I'm gonna do this for free in in you know my off time. Um, that would have been worth it, honestly, because I was I was not really, I wouldn't say I was very visible in the community before I worked on Reach. And once React Training broke up and and um you know Ryan tweeted out to his gajillion followers that we were all unemployed. Like, if it weren't for that, you know, getting laid off in in this sort of like economic uncertainty would have been super scary, you know? Yeah. Like, and I'm I feel so fortunate. Like, they they felt super bad about doing it. I was like, hey, this honestly, it could not have been a better way to get laid off because the The uh the fact that working on that project made my name uh something that some people at least recognized already. Um a lot of there are a lot of really like really solid developers and solid teams who are working on projects that use Reach UI. And we have a lot of great contributors. And I'm super fortunate for that. But then to have that um that added amplification in that kind of a time was just so useful to me. And it was such a just a very quick, jarring, but in a good way, um, adjustment to my career trajectory, I think. And again, if I had to go back and had the opportunity to do it for free, I probably would have done it because it's been, it's been such a help and it made the job search so much easier, less pain- less painful. And it puts you in this position to where you now have options, right? Like, I think developers take that for granted so much. Not even in tech, like-

[00:40:59] Michael Chan: Absolutely.

[00:41:00] Chance Strickland: Before I was doing this work on Reach, Like, I was working in agencies and freelancing, and that's like a whole different space that I think there's like this huge disconnect between product people and Silicon Valley developers and like the rest of the world when it comes to tech and and agencies especially. Like, those developers are not making 6 figures, right? Like, they're not-

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

[00:41:20] Chance Strickland: —living these glamorous lives that we see on Twitter or we think about when we think of like big tech salaries, right? Like, there's a- like, for every one of of like us, there's 20 people out there working in an agency who are slinging WordPress sites and they're launching products and you know they're just living living their lives doing their thing and um there's that disconnect there and uh

[00:41:42] Michael Chan: yeah

[00:41:42] Chance Strickland: you know to to have the opportunity to work on something as high-profile as ReachUI and with someone as high-profile as as Ryan and Michael was just such a huge benefit to to my prospects moving forward. Couldn't thank those guys enough.

[00:41:58] Michael Chan: That's awesome. Yeah, I think there's something- I mean, obviously working on a big project like that is amazing, but there's something about- there's something so valuable about being able to perform your work in a public space. Because, you know, when you- when you go to the next thing, it's like, hey, here's- here's my work. You might already be using it or like familiar with it. Um, but like, even if you aren't, like, you can see it. Like, this is Like, it's not hidden. Like, it's there if you want to look at it and see if I can do what you need me to do. Like, it's all there.

[00:42:30] Chance Strickland: Yeah. And when I was going through the interview process, uh, I mean, I had, you know, a handful of of uh folks wanted to give me coding tests and I was like, dude, like, my repo's right here. I've got references who you know, right? Like, why, why do I need this, like, 10-hour uh app challenge? Like. Talk to some people, right? Be a human about it. Again, are you LinkedIn or are you Twitter? Like, are you human or are you just some robot? Like, it's all there, right? And the job that I ultimately took, the interview process was way shorter than what it would have been at a lot of other places. And and for me, that's that's really valuable. I I don't have the patience for for some of these bigger companies with their the the rate at which they move or the pace at which they move. I mean, it's fine. Like, I I understand the value in in both sides, but like But for me, um, getting to talk to a few folks who um were willing to just actually talk to me and and look at my work and and let it speak for itself, um, it was super, super helpful. And I don't think I would have had that if it weren't for the work on Reach.

[00:43:30] Michael Chan: Yeah. Well, tell me real quick about your work. What's what's next? And are you able to take what you've learned from uh Reach and parlay that into the next thing?

[00:43:38] Chance Strickland: Absolutely. So, um, I just took an offer. Uh, with modules, uh, we are building— uh, we're building a lot of things. Um, so, I I don't want to like to misspeak here at any point. So, I would just uh check out modules. And that's modulz.app if you want to learn a little bit about modules. But uh modules is many things. One of the things that it is is a component library very similar to Reach. Uh, we are building out a large number of components. That will ultimately be used in this visual code editor that we're that we're also building. Um, but it's going to enable a lot of teams to create really awesome design systems, uh a lot like Reach UI does. So, uh very excited about that. Haven't started yet, but it's a it's a great team. They've got a really solid-looking product. And yeah, really excited to jump on that.

[00:44:29] Michael Chan: Killer. Hey, if there's one thing that you're super excited about for like kind of the not near term, but like maybe short-term future, like a year to 3 years out? Like what are you excited about? What do you think is gonna change in web development?

[00:44:41] Chance Strickland: So, one of the things that was really cool to me about modules is that they're building this um this low-code visual editing tool. And I am just so excited about low-code. Like that whole movement. Um there's this- so, you sort of have low-code and no-code. Um and everyone- I don't know. Everyone has their own ideas about what's going to to win the day. But I think I think application logic is is complex enough that you'll always need the ability to to write some code. But I think our tooling is still so far behind where we should be in terms of just ease of use, onboarding of of new learners, and also just developer experience. Like even if I can write a bunch of code, do I really want to be staring at a screen all day writing a bunch of code when I could just click a few buttons and get the the same result, like why wouldn't I do that? That's- like think of all the people you can empower to build products if you have tools that make it fun to build products.

[00:45:38] Michael Chan: Yeah.

[00:45:38] Chance Strickland: And maybe some people like looking at a terminal screen all day. But I I mean I'm not one of them. Like I don't want to do that. And I I'm super excited to see that space uh explode. I think modules is gonna be uh a key player in that that game. And I'm super excited to to help build it. Uh, but yeah, I'm I'm really bullish on on low-code and all of the the great tools that are going to emerge to empower people to build products.

[00:46:01] Michael Chan: Killer. Now, you have a great podcast. You're Chance the Dev all over the place. Could you tell me about where people can find you and also hear your your your smooth, sultry voice?

[00:46:13] Chance Strickland: No one's ever described it that way. Um, but I I do appreciate your your words, um, words of affirmation. You can find find me @chancethedev on Twitter. You can find me at chancethedev.com. You can listen to my podcast, which I am not religious about. I I've had some significant gaps in in publishing. Um not quite the beast mode that that Michael Chan is over here pumping out episodes of React Training— or React Training— React Podcast. Um but yeah, no, it's it's been a lot of fun. And we talk about— I I like to focus less on tech and more about the people in tech. Um, and I like to listen to people tell stories and and tell the story of their career and how they got involved in tech and and you know hear about what they want to do. So, um, those are the kinds of things I like to talk about. If that interests you at all, then you know, I'll I'll have some more episodes out pretty soon.

[00:47:01] Michael Chan: Killer. Well, Chance the Dev, thank you so much for your time today telling us about Reach and just kind of maintaining a modern open source project. Uh, hope to have you back on soon sometime.

[00:47:11] Chance Strickland: Dude, anytime. It's been awesome.

[00:47:13] Michael Chan: This has been episode 92 of React Podcast with me, Chantastic, and Chance Strickland. Find the people and projects mentioned in this episode at reactpodcast.com/92. Thanks to our sponsor, Infinite Red. If you're stuck in a React or React Native project, tap Infinite Red for help. They'll teach you your way out of whatever problem you face. Visit reactpodcast.com/ infinite.red to start a new project today and get 2 tickets to Chain React Conf in 2021. 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 All of our 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.