Giter Site home page Giter Site logo

task-react-filtering-pets's Introduction

In this task, we will make a website that looks like this. Here is a starting point fork and clone this repo

Pet The Pet!

  1. In PetItem.js, create a state for the pet image with an inital value of pet.image.
  2. Pass it to the image's src tag.
  3. Add an onClick to the button that changes the state from "pet.image to "pet.image2"
  4. Test your code, the button should change the image to a gif!

Search Bar

  1. In PetsList, create a state called query and a method called setQuery.
  2. In the input tag of SearchBar add an onChange method that calls setQuery() and gives it event.target.value as an argument.
  3. At this point, whatever you type in your search bar should appear in the query state in React Dev Tools.
  4. In your PetsList, filter your pets by comparing your pet's name with query using includes before you map your list so you can deal with plain javascript object.
  5. At this point, our search bar is case sensitive. Fix it so that it becomes case insensitive.

Filter Pets by specie

  1. in PetsList, create a state called type and a method called setType.
  2. In the select tag of PetSelector add an onChange method that calls setType() and gives it event.target.value as an argument.
  3. At this point, whatever you select in your selector should appear in the type state in React Dev Tools.
  4. In your PetsList, filter your pets by comparing your pet's type with type using includes.

Challenge

  1. Move all your search bar code to it's own component and pass setQuery as a prop to your new component.
  2. Move all your selector code to it's own component and pass setType as a prop to your new component.

task-react-filtering-pets's People

Contributors

yanalshmilan avatar engxli avatar lailz avatar omsi96 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.