Use it for truly components, internal UI state, because not all state is UI state. And ask yourself, is there a better pattern? Because there usually is, especially with React 19. And of course, there are docs as well. One of the most important docs that I feel like you should read is choosing the state structure because it goes through all of these strategies, grouping related states, avoiding contradictions and redundant state, avoiding duplication in states, which we talked about with derived state, and avoiding deeply nested state as well. So please make this required reading. So start with used state, refactor to better patterns, and focus on maintenance, because simple is better than easy. And so with that, thank you so much, React Summit.
All right. Okay. So we got a question from Andrew here. He's asking, is use memo a good alternative solution for handling derived state and ensuring it isn't recomputed each render? I would say use memo only when you need to because what you save in computation cost, you incur in memory cost with use memo. So if you have too many use memos, it could actually cause problems. It's one of those things where you'll know when you need it. It's like, wow, this is slow. This is causing a lot of calculation. So then use memo. And also React compiler, I think now if you use it, it is out right now, I believe. But you can actually use that instead of use memo, because it will automatically do all that. Yeah, that's a good question, Andrew.
Are there any existing linters to help encourage better practices around the use state? I believe there are, not to the extent that I talked about in this talk, but because sometimes it is hard to tell, like, hey, this date is derived, but it's not immediately obvious from traversing the AST or anything like that. But that's a good idea. I might write one. Oh, inspiring. It looks like the connection loss, but I got it. OK, and this one's from JD Collins. In 2025, is there still a place for Redux? Of course, yeah, especially with Redux toolkit. If you are still thinking about the old Redux, you know, with your actions dispatcher, etc., please, please give Redux toolkit a try. Honestly, it's only similar by name and by philosophy, but it's a very different API. I would say that you can't go wrong choosing a state management solution that helps you centralize your app logic, and Redux toolkit does that well, as Dustin does that well, Xstate and Xstate Store try to do that as well as I could.
Comments