Skip to content
This repository has been archived by the owner on Oct 1, 2023. It is now read-only.

Bookstore: Redux in React components #3

Merged
merged 13 commits into from
Jul 31, 2023
Merged

Conversation

lily4178993
Copy link
Owner

@lily4178993 lily4178993 commented Jul 31, 2023

Bookstore: Redux in React components

Description

In this step I used a Redux store to display books. I implemented react-redux in order to connect the store and then access thestate variables (accessed through useSelector) and state modifiers (which will be a combination of a reducer and useDispatch).

  • Setup a Redux store
  • Create a slice to save the state and reducers

Changes implemented

This PR is raised according to this requirements. The following changes have been done:

  • Wrap <App> with the <Provider> component from react-redux
  • Pass the configured store into the <Provider>
  • Create an initialState variable for the booksSlice, which will include the following:
    // Initial state:
    [
      {
        "item_id": "item1",
        "title": "The Great Gatsby",
        "author": "John Smith",
        "category": "Fiction"
      },
      {
        "item_id": "item2",
        "title": "Anna Karenina",
        "author": "Leo Tolstoy",
        "category": "Fiction"
      },
      {
        "item_id": "item3",
        "title": "The Selfish Gene",
        "author": "Richard Dawkins",
        "category": "Nonfiction"
      }
    ]
  • Display the books, received from the slice, in a reusable component
  • Dispatch actions using useDispatch
  • Add a <Button> component, which includes:
    • An event handler that adds a book to the books array (with attributes id, title and author)
  • Add a <Button> component, which includes:
    • An event handler that removes a book from the books array (by id)

Please kindly review our implementation and suggest any changes and improvements. 
Best regards.
Thanks for reviewing this PR 😊

Copy link

@bobb-Rob bobb-Rob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STATUS: APPROVED ✔️ 🍾 🍾 🍾 🥳 🥳 🥳

Hi @lily4178993,

Your project is complete! There is nothing else to say other than... it's time to merge it :shipit:
Congratulations! 🎉

Highlights

✅ All linters checks are ok
✅ The correct workflow is used.
✅ Very descriptive Pull Request(PR)
✅ Your work is well documented.

Optional suggestions

Every comment with the [OPTIONAL] prefix won't stop the approval of this PR. However, I strongly recommend you to take them into account as they can make your code better. Some of them were simply missed by the previous reviewer and addressing them will really improve your application.

Cheers and Happy coding!👏👏👏

Feel free to leave any questions or comments in the PR thread if something is not 100% clear.
Please, remember to tag me in your question so I can receive the notification.


As described in the Code reviews limits policy you have a limited number of reviews per project (check the exact number in your Dashboard). If you think that the code review was not fair, you can request a second opinion using this form.

@lily4178993
Copy link
Owner Author

Thank you @bobb-Rob for taking the time to review this branch.

@lily4178993 lily4178993 merged commit ee14d69 into dev Jul 31, 2023
3 checks passed
@lily4178993 lily4178993 deleted the features-interactions branch July 31, 2023 17:48
Repository owner locked as resolved and limited conversation to collaborators Aug 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants