GithubHelp home page GithubHelp logo

react-props-movie-lab-dc-web-082718's Introduction

React Props Movie Lab

Objectives

  1. Practice passing props from parent components to children
  2. Practice using default props
  3. Practice jumping into and improving existing code

Introduction

This is a barebones React application used to showcase the nine greatest movies of all time. Your job is to update it so that it passes props from parent to children components correctly. In addition, you will implement default props so that 'bad/missing data' is properly handled - preventing our user interface from blowing up our visitors' computers

Following is the component tree. When fully rendered, there are 9 MovieCards rendered by MovieShowcase:

└── MovieShowcase
    │
    ├── MovieCard
    │   ├── CardFront
    │   └── CardBack
    │
    └── MovieCard
        ├── CardFront
        └── CardBack

MovieShowcase is the component that will house all of the 'raw' data associated with the movies we want to display. This data is located in src/data.js and is already being imported.

MovieCard components (which showcase a single movie) receive their individual movie information from MovieShowcase as four props: title, IMDBRating, genres, and poster. Following, the props are passed again to either CardFront or CardBack.

In our movie data set, we occasionally have missing data. This is where defaultProps come in and really pull our buns out of the fire. We will be handling all of our defaultProp'ing in MovieCard before they are passed down the chain to the front and back components.

Deliverables

MovieShowcase
  1. .map over the imported movie data array and render MovieCards for each element. (see documentation)
  2. Don't forget to pass all 4 props
MovieCard
  1. defaultProps should be assigned in MovieCard for all four of the props:
  • title receives an 'Unknown' string
  • IMDBRating simply gets assigned to null
  • genres should receive a value that will work with our CardBack component's rendering method for genres. The screen should read: 'No Genre(s) Found'
  • poster should get the string default
  1. pass the correct props to the correct back/front components (Note: the posterMap already takes care of converting a string into the appropriate poster asset)
CardFront
  1. the prop should be used to apply a background image. This can be done inline via:
style={{backgroundImage: `url(${prop})`}}
CardBack
  1. render the genres (as comma separated) strings
  2. render the title value
  3. Finish writing the method generateRatingElement, which should do the following:
  • if the IMDBRating prop is null, return an <h4> with the contents 'No Rating Found'
  • otherwise, return <img src={imgMapper[prop]} alt="" /> (using the correct prop)

Once Finished

npm start and make sure everything is functioning how you would like!

Resources

View Props Lab on Learn.co and start learning to code for free.

react-props-movie-lab-dc-web-082718's People

Contributors

danielseehausen avatar maxwellbenton avatar

Watchers

 avatar Kevin McAlear avatar  avatar Victoria Thevenot avatar Belinda Black avatar  avatar Joe Cardarelli avatar Sam Birk avatar Sara Tibbetts avatar The Learn Team avatar Sophie DeBenedetto avatar  avatar Jaichitra (JC) Balakrishnan avatar Antoin avatar Alex Griffith avatar  avatar Amanda D'Avria avatar  avatar A. Perez avatar Nicole Kroese  avatar  avatar Lore Dirick avatar Nicolas Marcora avatar Lisa Jiang avatar  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.