From the course: React: Software Architecture
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Sharing Recoil state
From the course: React: Software Architecture
Sharing Recoil state
- [Narrator] Okay, before we move on from recoil, there are a few more things that I want to show you that are important to know before using it. The first thing I want to show you is how recoil allows our components to share state. So before we do that, let's start by deleting some of our unneeded imports here. Just to clean up a little bit. First of all, let's imagine that our application has two CounterButtons instead of one. Well, with recoil, these will automatically share their state. So let's take a look at this in our browser, and we can see that if we click on this, it will automatically increment both. And if we change the incrementBy, since that's using recoil as well, that will automatically make the exact same change to both as well. Now this may or may not be what you want, which is why it's important to know that this is a basic feature of recoil. If we were using the useState hook like we saw before,…
Contents
-
-
-
-
-
(Locked)
What is state management?3m 25s
-
(Locked)
Small state with the useState Hook5m 20s
-
(Locked)
Small state with context5m 48s
-
(Locked)
Accessing context inside components4m 53s
-
(Locked)
Medium state with Recoil6m 7s
-
(Locked)
Sharing Recoil state6m 49s
-
(Locked)
Using Recoil selectors5m 9s
-
(Locked)
Big state with Redux6m 29s
-
(Locked)
Using Redux with components8m 1s
-
(Locked)
Big state with MobX7m 48s
-
(Locked)
-
-
-
-