Day 1: title formatting coherence, other edits

This commit is contained in:
Elizabeth Craig
2019-03-05 02:20:22 -08:00
parent 886738d12a
commit 8c99c83353
17 changed files with 133 additions and 104 deletions

View File

@@ -1,19 +1,19 @@
# Step 1-05: Demo Building a Static Page
# Step 1.5 - Building a static page in React (Demo)
To start off our todo application we are going to follow the steps outlined in [Thinking in React](https://reactjs.org/docs/thinking-in-react.html). The first step of the process is to break our application into a component hierarchy. For this app, we're going to keep it simple and just use four parts.
To start building our todo application, we'll follow the steps outlined in [Thinking in React](https://reactjs.org/docs/thinking-in-react.html). The first step of the process is to break our application into a component hierarchy. For this app, we're going to keep it simple and just use four parts.
- TodoHeader
- TodoList
- TodoListItem
- TodoFooter
You can find the HTML for our application in `step1-05/TodoApp.html`
You can find the HTML for our application in `step1-05/TodoApp.html`.
## TodoHeader
We are going to store all of our components inside of a `components` folder. Lets create that now. We'll then start with the `TodoHeader` inside of a file called `TodoHeader.tsx`. This file format tells our application that this file includes React code written in Typescript.
We'll store all of our components inside a `components` folder under `src`. Let's create that now. We'll then start writing the `TodoHeader` in `components/src/TodoHeader.tsx`. The `tsx` file extension tells our editor that this file includes React code written in TypeScript.
> We'll talk about Typescript soon, but for now know that all valid JavaScript is valid Typescript
> We'll talk about TypeScript soon, but for now, know that all valid JavaScript is valid TypeScript.
```jsx
import React from 'react';
@@ -38,7 +38,7 @@ export class TodoHeader extends React.Component<any, any> {
}
```
> Note that since this is React we had to change `class` to `className`, but nothing else changes.
> Note that since this is React, we had to change `class` to `className`, but nothing else changes.
## TodoListItem
@@ -60,4 +60,15 @@ export class TodolistItem extends React.Component<any, any> {
}
```
> Note that this control could also be created as a function instead of a class: `export const TodoListItem = (props) => {}`
> Note that this control could also be created as a function instead of a class:
> ```jsx
> export const TodoListItem = (props) => {
> return (
> <li className="todo">
> <label>
> <input type="checkbox" /> Todo 1
> </label>
> </li>
> );
> }
> ```

View File

@@ -1,16 +1,20 @@
# Step 1-06 Exercise
# Step 1.5 - Building a static page in React (Exercise)
### TodoFooter
From this exercise on, we'll be working in VS Code instead of CodePen. If you don't already have the bootcamp folder open in a VS Code window, see the [main readme](https://github.com/Microsoft/frontend-bootcamp/blob/master/README.md) for instructions.
1. Add a TodoFooter component in the `components` folder, copying over the `<footer>` tag and all of its children from `TodoApp.html` in the `step1-05` folder. This could be a function or class.
If you don't already have the app running, start it by running `npm start` from the root of the `frontend-bootcamp` folder. Click the "exercise" link under day 1 step 5 to see results.
## TodoFooter
1. Add a TodoFooter component in the `components` folder, copying over the `<footer>` tag and all of its children from `TodoApp.html` in the `step1-05` folder. This component could be a function or class.
2. Remove any `onclick` properties, and change `class` to `className`
### TodoList
## TodoList
1. Add a TodoList component like you did with the footer. This could also be function or class.
2. Import TodoListItem and add 4 of them inside of the `<ul>`
2. Import TodoListItem and add four of them inside of the `<ul>`
3. Bonus points for using a [`for`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration) loop or using [`map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) to create 4 list items based on the array `[1,2,3,4]`
## App.tsx
## App
1. Import both of these components into `App.tsx` and place their tags below the `TodoHeader`.