Giter Site home page Giter Site logo

react-hooks-state-and-events-lab's Introduction

React State Lab

Learning Goals

  • Update state based on events
  • Work with multiple state variables together

Introduction

In the labs for this section, we'll be working on a grocery list app. Some of this app is already built out using static versions of the components. We'll be using state and events to make our app dynamic.

The components you have to work with are in the src/components folder. Start by examining these components and draw out your component hierarchy to see how data can be passed from one component to another.

In this lab, you'll update state and get more practice with the useState hook.

It's recommended that you run npm start and work on this in the browser before running tests. Try to get your app to match the demo! Once you've built out the components below, run npm test to see if your code passes the tests.

demo

Deliverables

Filter

In the ShoppingList component, there is a <select> element that will allow us to filter the list of items by category.

Use the useState hook to create a state variable called selectedCategory for keeping track of the selected value from this <select> element. When the value of the <select> element is changed, update state.

You should also use the selectedCategory variable to determine which items to display in the shopping list. You'll need some way of filtering the array of items based on the selectedCategory.

Resources

react-hooks-state-and-events-lab's People

Contributors

ihollander avatar lukeghenco avatar maxwellbenton avatar lizbur10 avatar thomastuts avatar graciemcguire avatar annjohn avatar gj avatar jlboba avatar sylwiavargas avatar wolterpynaffit avatar pletcher avatar kjleitz avatar gehrig-barnes avatar sbalayan1 avatar

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.