GithubHelp home page GithubHelp logo

cdaz5 / react-initial-state-lab-web-051517 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brettschules/react-initial-state-lab-web-051517

0.0 2.0 0.0 451 KB

License: Other

Shell 11.42% HTML 20.64% JavaScript 67.93%

react-initial-state-lab-web-051517's Introduction

React Initial State Lab

Overview

In this lab, you'll set initial state in a React component and distinguish between state and props.

Image slider

Let's pretend we're making an awesome slider for our new portfolio site. Naturally, we'll use React to do so! We have to start somewhere, so in this lab we'll just focus on setting up the initial state of the slider.

  1. In the components/ImageSlider.js file, create an ImageSlider React component.
  2. Its initial state should have a property called currentSlideIndex that starts at 0.
  3. It should only render out the text 'I am on slide <CURRENT_SLIDE>', where <CURRENT_SLIDE> is the value of this.state.currentSlideIndex.

A bomb timer

Take a moment to think about what a bomb does and how it works. Don't get all into the nitty gritty โ€” what we're going to focus on right now is the timer. Let's create a component that represents a bomb timer that counts down until it reaches 0. However, the only thing we're going to focus on right now is setting the initial state of the bomb: the amount of seconds left on the timer. Since bomb timers can differ, we'll pass in a prop to our Bomb component to determine what the starting count should be.

  1. In the components/Bomb.js file, create a Bomb React component.
  2. Its initial state should have a property called secondsLeft.
  3. The initial value of secondsLeft is set by passing in an initialCount prop to the Bomb component. Don't forget to pass the argument props into the constructor (i.e., constructor(props)).
  4. It should render the text '<SECONDS_LEFT> seconds left before I go boom!', where <SECONDS_LEFT> is the value of secondsLeft.
  5. If secondsLeft equals 0, it should render 'Boom!' instead.

Resources

react-initial-state-lab-web-051517's People

Contributors

lukeghenco avatar thomastuts avatar annjohn avatar gj avatar aturkewi avatar pletcher avatar enoch2k2 avatar jremes-foss avatar kjleitz avatar nikymorg avatar

Watchers

James Cloos avatar Chris D'Ascoli 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.