[Suggestion]: Fix the data.js
file part of the solution for Challenge 4 in "Choosing the State Structure" chapter
#7394
Labels
Summary
The
data.js
provided in the solution for "Challenge 4" has a property calledisStarred
which is unused in the provided solution for the challenge:export const letters = [{ id: 0, subject: 'Ready for adventure?', - isStarred: true, }, {
Thus my suggestion is to remove the
isStarred
property fromdata.js
file in challenge 4Page
https://react.dev/learn/choosing-the-state-structure#recap
Details
The presence of the unused
isStarred
property can potentially confuse a beginner following the documentation, because they might have gone through the section on Avoiding Redundant States. I mean to say that they might end up writing a solution which utilises theisStarred
property like shown below, which also solves the challenge:Although the above solution works, it has the following cons:
Tight Coupling
: OverloadingisStarred
for both "selected" and "starred" behaviours creates coupling between two potentially distinct concepts. If the app later needs to treat "starred" and "selected" as separate attributes, refactoring will be necessary.Side Effects
: ModifyingisStarred
might have unintended consequences elsewhere in the app if other features or components depend on it strictly representing "starred" status.The text was updated successfully, but these errors were encountered: