Redux toolkit react native11/19/2023 These three libraries all work together seamlessly in both React and React Native, and while the depth of functionality they provide together may sound intimidating or complex, bootstrapping an app with them is actually surprisingly straightforward. reload the data into state when a user returns). The library helps you both to save your data in the first place, as well as “hydrate” your app (i.e. You won’t need this for every project, but when you do need to store data it’s great. ![]() save) your data more permanently (across page refreshes, app closes and sessions). Redux Toolkit is the real magic for me though - where Redux alone can be a little finicky to set up, Redux Toolkit (an additional library) massively simplifies the process and, to be honest, is pretty much the only reason I was ever able to figure out and embrace Redux full stop.įinally, Redux Persist is an optional further library which allows you to easily “persist” (i.e. This extracts a lot of data-related logic from your component files, allowing them to focus solely on rendering the UI and, critically, allows you to easily read from and write to any part of your state, from any of your components, without having to worry about passing loads of data and methods up and down through props. I won’t go too in-depth here, as if you’ve landed on this post you likely know the basics and just need some boilerplate to get it set up in your app, but the tl dr is - Redux is a library (and general development pattern) which allows you to store and manage state globally, instead of on a component by component level. What are Redux, Redux Toolkit and Redux Persist? This is pretty much a bare minimum as far as Redux goes, but I have rarely found much need for anything else. I’ve found a lot of tutorials on Redux setup to be a bit lacking - either configuring things in a more complex way than I require, or glossing over exactly what’s going on so I never truly understand what bits I need - so I thought I’d have a go at my own. I personally learn best from reading example code, as opposed to digging through technical documentation. As a result my React apps are now so much more robust, easy to reason about, and scalable. When I finally sat down and figured it out (thanks in huge part to Redux Toolkit) I couldn’t believe what I had been missing out on. Ironically I was making things much harder for myself by avoiding it.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |