-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e2e614e
commit 51a9881
Showing
10 changed files
with
202 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,21 @@ | ||
# Lift State | ||
|
||
🧝♂️ I refactored the app a bit. In the process I kinda broke stuff and you'll be | ||
required to fix it. Feel free to <DiffLink app1={-1}>check the diff</DiffLink> | ||
to know what I've done. I pretty much just moved stuff into separate components | ||
to get a little more organization in here. | ||
|
||
<callout-info> | ||
🦉 check out [When to break up a component into multiple | ||
components](https://kentcdodds.com/blog/when-to-break-up-a-component-into-multiple-components). | ||
</callout-info> | ||
|
||
🧝♂️ Oh, also I added a new feature. You can now "like" specific posts by clicking | ||
a little heart on the post. How nice! It's not persisted anywhere yet, so when | ||
you refresh the page the likes all get reset, but it's a nice start! | ||
|
||
👨💼 Great, now your job is to fix what's broken. You need to move not only the | ||
state, but also we're going to have you move the `useEffect` that sets the query | ||
as well. | ||
|
||
Then you're going to need to pass props to the components as needed. Enjoy! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
# Lift State | ||
|
||
👨💼 Great! It's working now! | ||
|
||
Hmmm... What's that I hear? It's the sound of a new requirement coming in! 😆 |
11 changes: 11 additions & 0 deletions
11
exercises/03.lifting-state/02.problem.lift-array/README.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,12 @@ | ||
# Lift More State | ||
|
||
👨💼 The users loved 🧝♂️ Kellie's like feature so much they want to have the blog | ||
posts sorted by whether they're favorites. | ||
|
||
🧝♂️ I've already created the sort function. Now you need to add the logic to sort | ||
them based on whether they're favorited. And that means you need to lift some | ||
state... | ||
|
||
👨💼 Yep. We're going to need you to lift the favorited state from the cards to | ||
the `MatchingPost` component. We'll also need to restructure it slightly as | ||
well. Don't worry. The emoji will guide you. Good luck! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# Lift More State | ||
|
||
👨💼 Great job! Unfortunately... I have some bad news. Let's talk about that next. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
# Colocate State | ||
|
||
👨💼 Well, the users thought they wanted the articles sorted by whether they were | ||
favorited... But after using the feature, they found it to be jarring and | ||
confusing. So we're going to need you to remove that feature. Kellie already | ||
removed the sorting for you, but she didn't have time to move the state back to | ||
the `Card` component. | ||
|
||
As a community we're pretty good at lifting state. It becomes natural over time. | ||
One thing that we typically have trouble remembering to do is to push state back | ||
down (or | ||
In fact it's required to make the feature work. But as you notice here, the | ||
functionality we want is already "working" without moving any of the state | ||
around so it's easy to forget to improve the performance and maintainability of | ||
our code by moving state back down (or | ||
[colocate state](https://kentcdodds.com/blog/state-colocation-will-make-your-react-app-faster)). | ||
|
||
So your job is to move the `favorited` state back to the `Card` component. | ||
|
||
When you're finished, the functionality should be no different, but the code | ||
should feel simpler. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
# Colocate State | ||
|
||
👨💼 Awesome! You now know how to colocate state! Try to do this as much as | ||
possible in the future. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# Lifting State | ||
|
||
👨💼 Hooray! You've learned how to move state around as needed like a pro! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters