GithubHelp home page GithubHelp logo

phoebelau1 / react-information-flow-v-000 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from learn-co-students/react-information-flow-v-000

0.0 0.0 0.0 173 KB

License: Other

HTML 22.13% CSS 34.11% JavaScript 43.76%

react-information-flow-v-000's Introduction

Objectives

  • Practice enforcing React up-down information flow
  • Practice debugging

Getting Started

Take a moment to familiarize yourself with the code base. We have a simple application that renders 3 unique components: Tier1, Tier2, and Tier3. Following is what our component structure looks like when fully rendered:

App
├───Tier1
│   ├───Tier2
│   │   └───Tier3
│   │   └───Tier3
│   └───Tier2
│       └───Tier3
│       └───Tier3
└───Tier1
    ├───Tier2
    │   └───Tier3
    │   └───Tier3
    └───Tier2
        └───Tier3
        └───Tier3

src/randomColorGenerator.js has a few helper functions implemented for you that generate random colors, as well as lighter tints of a specific color.

Deliverables

Understanding that React components should communicate up and down the component tree, we want to make sure that the following behavior is exhibited:

  • When a Tier component is clicked it, and all other components within the same parent, should change colors (i.e. If a Tier2 component is clicked, the other Tier2 within the same parent component should also change color)
  • When a component's color changes all of its children components should change to a lighter shade of the same color (use the imported getReducedColor function)
  • Components of the same level should never communicate directly! For example, when a tier3 component is clicked, it should communicate this up the component tree (i.e. via a callback method that was passed).

The color changing functionality itself has already been implemented -- while you should feel free to, there is no need to alter the existing code in src/randomColorGenerator.js

A lot of starter code has been provided. Ultimately, you should only need to make minimal changes. While the React application is rendering without any bugs, not all of the provided code in our Tier1 and Tier2 components is what we want it to be! Be critical and make changes where appropriate.

Example

The gif below shows what a fully working application should look like. While you won't be generating identical colors, the functionality should be the same:

You will notice that even if children components change colors without their parents, a changing of their parents' colors resets them.

Refactoring

Several different solution branches have been provided. Please complete your own solution before taking a look at them:

  • Did your's match any of the same patterns, or was it a novel solution?
  • How could we make our application more DRY?

react-information-flow-v-000's People

Contributors

danielseehausen avatar phoebelau1 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.