Giter VIP home page Giter VIP logo

react-hooks-state-events-mini-project's Introduction

Putting it All Together: State and Events

Learning Goals

  • Use state and events to make components dynamic
  • Implement controlled components

Introduction

To build on what you've learned over the course of this section, we'll be building out a simple task list app to practice working with state and events, focusing in particular on working with arrays.

Deliverables

There is some starter code built out for all of the components you'll need. The data for the application is imported in App, so you'll need to pass that data down to the components that need it as props.

Run npm install and npm start, then check out the starter code in the browser. You'll see a console message with the TASK and CATEGORY data you'll need to pass down from App.

TaskList

First, we'll want to display all the tasks in our app. Pass down the task data from App to TaskList, and display each task using the Task component. Make sure to use a key prop!

Task

Update the Task component so that it shows the task's text and category.

When the delete button is clicked, the task should be removed from the list.

CategoryFilter

Pass the list of categories to this component from App. Then, update this component to display <button> elements for each category. In order to pass the test, the buttons will need a key prop equal to the category.

When a button is clicked, the following should happen:

  • Whichever button was clicked should have a class of selected. The other buttons should not have any class assigned.
  • The list of tasks being displayed should be filtered, so that only tasks that match the category that was clicked are displayed.
  • If the button for "All" is selected, all the tasks should be displayed.

NewTaskForm

Pass the list of categories to this component from App. Then, update this component to display <option> elements for each category inside of the <select> element except the "All" category, so that the user can select a category when adding a new task.

Next, update this form to be a controlled component, so that all form inputs are captured in state.

When the form is submitted, add a new task to the list with the text and category from the form. For the tests for this feature to pass, you'll need a callback prop named onTaskFormSubmit that takes a task object as an argument.

react-hooks-state-events-mini-project's People

Contributors

ihollander avatar jlboba avatar lizbur10 avatar mkdoh3 avatar schazbot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-hooks-state-events-mini-project's Issues

Suggestion

This lab is good, however, I see one issue that I think could help other students. There is a section of the instruction under "CategoryFilter" that says "The list of tasks being displayed should be filtered, so that only tasks that match the category that was clicked are displayed.". However, it does not clarify that it is ok if, when instrumented, that this handler will also show any tasks that were previously deleted (this is because we are not deleting them in the database and thus they will come back with the re-render. I clarified this with Brooke. It might be good to include a line in the instruction that says "It is ok if, when you click a new category, the tasklist shows tasks that were previously deleted (we will cover how to do this in a later section once we update the database while also changing state)." (or something to that effect).

Test cases that restrict implementation options more than test proper functionality of components

Canvas Link

https://learning.flatironschool.com/courses/4993/assignments/167774?module_item_id=362480

Concern

It's entirely possible that I'm missing something about why the tests needed to be this way but I ran into some issues with I think unnecessarily closeminded tests. By that I mean I think my code was working just fine but I had to restructure my code because:
1: Theres a test that forces you to pass a task object to the callback function onTaskFormSubmit. (i.e. you can't just pass the text and category as two separate parameters, or some other implementation.
2: There's a test for the tasks initially being declared that passes only tasks to TaskList... i.e. ... So if in your implementation you pass a category, or callback function to TaskList, you'll fail that test even if your App has the desired behavior. I'm pretty sure that test is bad and you should be allowed to pass other props to TaskList than solely "tasks"... or if you're not allowed to do that for some reason... setting default values for my category made the test pass. Screenshot of this issue attached.
Screen Shot 2022-02-25 at 6 52 29 PM

Additional Context

No response

Suggested Changes

Make tests more generic or give more guidance in the canvas explanation of what restrictions the tests impose.

Suggestion for project requirements description

Canvas Link

https://learning.flatironschool.com/courses/5256/assignments/219934?module_item_id=512769

Concern

This lab is good, however, I see one issue that I think could help other students. There is a section of the instruction under "CategoryFilter" that says "The list of tasks being displayed should be filtered, so that only tasks that match the category that was clicked are displayed.". However, it does not clarify that it is ok if, when instrumented, that this handler will also show any tasks that were previously deleted (this is because we are not deleting them in the database and thus they will come back with the re-render. I clarified this with Brooke.

Additional Context

No response

Suggested Changes

It might be good to include a line in the instruction that says "It is ok if, when you click a new category, the tasklist shows tasks that were previously deleted (we will cover how to do this in a later section once we update the database while also changing state)." (or something to that effect).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.