JS-201-ReactFundamentals
  • Part 0: App Overview
  • Part 1: Intro to React
    • 1.0: Packages Setup
    • 1.1: Project Setup
    • 1.2: React Router Dom
  • Part 2: JavaScript Concepts
    • 2.0: ES6 Overview
    • 2.1: classes
    • 2.2: constructors
    • 2.3: extends
    • 2.4: super
    • 2.5: interpolation
    • 2.6: map
    • 2.7: filter
  • Part 3: Functional Components
    • 3.0: Functional Components Overview
    • 3.1: Calling Functional Components
    • 3.2: Single Element Rule
    • 3.3: Arrow Functions
    • 3.4: Challenge
    • 3.4: Solution
    • 3.5: Challenge 2
    • 3.5: Solution 2
  • Part 4: JSX Challenge
    • 4.1: JSX Overview
    • 4.1: Challenge Answer
    • 4.2: className
  • Part 5: Class Concepts
    • 5.1: State
    • 5.2: setState
    • 5.3: Class Components Challenge
    • 5.4: Class Components Challenge Answer
  • Part 6: Props Starter
    • 6.0: Props Overview
    • 6.1: Props Demo and Challenge 1
    • 6.2: Props Answer 2
    • 6.3: Props Passing Functions and Challenge 2
    • 6.4: Props Answer 2
    • 6.5: External Props and Mapping Components
    • 6.6: PropTypes
  • Part 7: Lifecycle Methods
    • 7.0: Lifecycle Overview
    • 7.1: Lifecycle Methods
    • 7.2: Mounting Methods
    • 7.3: Update Methods
    • 7.4: Unmount Methods
  • Part 8: Apps
    • 1.0 - Small Timer Apps
      • 1.1 - Simple Timer
      • 1.2 - Clock App
      • 1.3 - Stop Watch App
      • 1.4 - Challenge
    • 2.0 - Concept List
      • 2.1 - Concept Data
      • 2.2 - Concept App Component
      • 2.3 - Concept Component
      • 2.4 - Concept List Component
    • 3.0 - NYT
      • 3.1 - NytApp Component
      • 3.2 - Nyt Results
    • 4.0 - The Friend List App
      • 4.1 - Friend List App Component
      • 4.2 - Friend Component
    • 5.0 - Movie Search Application
      • 5.1 - Form Component
      • 5.2 - Form Results Component
      • 5.3 - Styled Components
    • 6.0 - YouTube Api
      • 6.1 - Video Component
      • 6.2 - Video Component
      • 6.3 - Video Component
    • 7.0 - Github Api Application
      • 7.1 - The Users
      • 7.2 - Github API Component
      • 7.3 - Github API Card
      • 7.4 - Github API Card Form
      • 7.5 - Github API Card List
      • 7.6 - Github API Search
      • 7.7 - Github API Challenge
    • 8.0 - Bitcoin Api Application
      • 8.1 - Bitcoin API Setup
      • 8.2 - Bitcoin API Fetch
      • 8.3 - Bitcoin API Line Chart
      • 8.4 - Bitcoin API Fetching Data
      • 8.5 - Bitcoin API Info Box
      • 8.6 - Bitcoin API Completed Code
    • 9.0 - Google Maps Api Challenge
    • 10.0 - Sound Cloud App Challenge
    • 11.0 - VR App Challenge
    • 12.0 - React Native Intro
  • Part 9: Project
  • Part 10: Notes
    • 10.1 - Resources
    • 10.2 - Troubleshooting
Powered by GitBook
On this page
  • What We're Going to Build & Learn
  • Getting Started
  • Simple Timer Setup
  1. Part 8: Apps

1.0 - Small Timer Apps

What We're Going to Build & Learn

  • A collection of time based apps

  • This app will include a lot of use of lifecycle methods, as well as props and state practice.

Getting Started

Before we start on our first timer app, we first need to add a folder for this app to our files. Underneath our apps folder, create a new folder called "timer-apps".

    └── src
        └── assets
        └── components
                └── apps
                    └── timer-apps

Inside of our timer-apps folder, we're going to create our components for this timer application. The first component we will make will be the parent component for this app, like App.js is for our overall React application. Create a file called "TimePiecesApp.js" inside our timer-apps folder. Ensure, like always, that this is capitalized, as it is a react component.

    └── src
        └── assets
        └── components
                └── apps
                    └── timer-apps
                        └── TimePiecesApp.js

In this application, we're going to learn more lifecycle methods, separating concerns in different components, and utilize some more ES6 functionality.

To get started we need to adjust our Sidebar.js, so that we have a way of navigating to our new mini-react app.

In your Sidebar.js file we need to add a route to our TimePiecesApp. Underneath the rest of your routes, you'll need to add one for the timer apps.

<Route exact path="/timer"><TimePiecesApp /></Route>

In your Sidebar.js, you'll need to add a way to utilize this new route. Add the following to the file, underneath your other links. Don't forget to import TimePiecesApp as well!

    <li><Link to="/timer">Timers</Link></li>

As our TimePiecesApp file is the parent component for our different little timer applications, we really only need our parent component in this instance to render the child components. Since we're not worried about state, we can go ahead and just make TimePiecesApp a functional component.

Go ahead and type the following code out in your TimePiecesApp.

import React from 'react';
import TimerApp from './TimerApp';
import ClockApp from './ClockApp';
import StopWatchApp from './StopWatchApp'


const TimePiecesApp = () => {
    return (
        <div className="main">
            <div className="mainDiv">
                <TimerApp />
                <hr />
                <ClockApp />
                <hr />
                <StopWatchApp />
            </div>
        </div>
    )
}

export default TimePiecesApp;

When you try and run this, what do you think is going to happen? Go ahead and check out your app, and see if you were correct.

You should see an error like this:

./src/components/apps/timer-apps/TimePiecesApp.js
Module not found: Can't resolve './ClockApp' in 'whereveryourappislocated/src/components/apps/timer-apps'

If you were correct, you would have guessed that it wouldn't run because it cannot find our TimerApp, ClockApp and StopwatchApp, since we haven't yet made them! In the next few chapters, we're going to go through each of these timer apps and create them.

Simple Timer Setup

Next, we'll get started on setting up our first timer app!

PreviousPart 8: AppsNext1.1 - Simple Timer

Last updated 7 years ago

Simple Timer Setup