Giter VIP home page Giter VIP logo

react-dq-props-state's Introduction

Discussion Questions: Exploring Props and State Further

In this program, we have three components: App, MasterHog, and BabyHog.

MasterHog:
  • Has an eye color that can change via a radio button on the DOM
  • Renders three BabyHogs, which inherit its eye color
  • Owns the non-variable data associated with each BabyHog. This includes their: name, eye color, and hobby. (Obviously, MasterHog gets to name her babies, and they genetically inherit her eye color. Not obviously, MasterHog also gets to determine their hobbies) Look inside src/db.js to see data defining what the BabyHog offspring should "inherit."
BabyHog:
  • Has an eye color received from its parent
  • Has a hobby assigned by its parent
  • Has a name given by its parent
  • Has a variable weight, that can be changed via buttons

Note: While the MasterHog component can change its own eye color via radio buttons, its children can only inherit the eye color of their parent!

Directions:

  • Understanding the data associated with both the MasterHog as well as the BabyHog components, plan out what data should be kept as state vs. props in each component and then implement it
  • Make use of the src/db.js file (import it!). Hint: arrays can be mapped and return JSX! Just because the starter code has three BabyHog components written in doesn't mean it's an ideal solution
  • Depending on the BabyHog eye color, a different image should be rendered (several are being imported in the BabyHog component)
  • While the changeWeight method has been implemented in BabyHog, it is not 'hooked up' to the component. Make sure the function is invoked so our hogs can grow and shrink when either of the buttons are clicked. (Consider how MasterHog's changeEyeColor method is 'hooked up' if you are stuck here)

react-dq-props-state's People

Contributors

lizbur10 avatar dependabot[bot] avatar danielseehausen avatar geluso avatar maxwellbenton avatar mmacdonald1 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.