├── .gitignore ├── LICENSE ├── README.md ├── db.json ├── package.json ├── public ├── favicon.ico └── index.html └── src ├── App.css ├── App.js ├── App.test.js ├── components ├── router │ ├── Link.js │ ├── Router.js │ └── index.js └── todo │ ├── Footer.js │ ├── TodoForm.js │ ├── TodoItem.js │ ├── TodoList.js │ └── index.js ├── index.css ├── index.js ├── lib ├── todoHelpers.js ├── todoHelpers.test.js ├── todoService.js ├── utils.js └── utils.test.js └── logo.svg /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | 6 | # testing 7 | coverage 8 | 9 | # production 10 | build 11 | 12 | # misc 13 | .DS_Store 14 | .env 15 | npm-debug.log 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Andrew Van Slaars 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Project Setup 2 | 3 | These instructions are for running the completed application created in the Egghead.io course [Build Your First Production Quality React App](https://egghead.io/courses/build-your-first-production-quality-react-app) 4 | 5 | ## Get The Code 6 | 7 | From a terminal, clone this repo into the folder of your choosing (in this example, I'm using `egghead-todo`) 8 | 9 | * `git clone git@github.com:avanslaars/egghead_react_todo_app_course.git egghead-todo` 10 | 11 | Then install the project dependencies with npm. **Be sure to `cd` into the project root first** 12 | 13 | * `npm install` 14 | 15 | To run this application, you will need to have the mock API server **and** the web pack dev server running in separate terminal sessions. 16 | 17 | ## Setup The API Server 18 | 19 | This project uses [json-server](https://github.com/typicode/json-server) to provide a local REST service that uses a `.json` file as its data source. For more information on how to use json-server, there is an egghead video available: [Egghead.io free video tutorial - Creating demo APIs with json-server](https://egghead.io/lessons/nodejs-creating-demo-apis-with-json-server) 20 | 21 | 22 | 23 | ### Install json-server 24 | 25 | You can install it globally with `npm i -g json-server`. This is a one-time setup. 26 | 27 | 28 | 29 | ### Running json-server 30 | 31 | Be sure to `cd` into the project's root directory. From there, run: 32 | 33 | * `json-server -p 8080 db.json` 34 | * This will run the server on port `8080` and use `db.json` as the data source 35 | 36 | ## Running the Project 37 | 38 | In a separate terminal session from the API server, you can start the React application with the included npm script 39 | 40 | * `npm start` 41 | 42 | This will run the `webpack-dev-server` that is configured through `create-react-app` 43 | 44 | ## Running the tests 45 | 46 | In a separate terminal session, you can start the unit tests with the included npm script 47 | 48 | * `npm test` 49 | 50 | --- 51 | 52 | This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app). 53 | 54 | Below you will find some information on how to perform common tasks.
55 | You can find the most recent version of this guide [here](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md). 56 | 57 | ## Table of Contents 58 | 59 | - [Updating to New Releases](#updating-to-new-releases) 60 | - [Sending Feedback](#sending-feedback) 61 | - [Folder Structure](#folder-structure) 62 | - [Available Scripts](#available-scripts) 63 | - [npm start](#npm-start) 64 | - [npm test](#npm-test) 65 | - [npm run build](#npm-run-build) 66 | - [npm run eject](#npm-run-eject) 67 | - [Displaying Lint Output in the Editor](#displaying-lint-output-in-the-editor) 68 | - [Installing a Dependency](#installing-a-dependency) 69 | - [Importing a Component](#importing-a-component) 70 | - [Adding a Stylesheet](#adding-a-stylesheet) 71 | - [Post-Processing CSS](#post-processing-css) 72 | - [Adding Images and Fonts](#adding-images-and-fonts) 73 | - [Using the `public` Folder](#using-the-public-folder) 74 | - [Adding Bootstrap](#adding-bootstrap) 75 | - [Adding Flow](#adding-flow) 76 | - [Adding Custom Environment Variables](#adding-custom-environment-variables) 77 | - [Can I Use Decorators?](#can-i-use-decorators) 78 | - [Integrating with a Node Backend](#integrating-with-a-node-backend) 79 | - [Proxying API Requests in Development](#proxying-api-requests-in-development) 80 | - [Using HTTPS in Development](#using-https-in-development) 81 | - [Generating Dynamic `` Tags on the Server](#generating-dynamic-meta-tags-on-the-server) 82 | - [Running Tests](#running-tests) 83 | - [Filename Conventions](#filename-conventions) 84 | - [Command Line Interface](#command-line-interface) 85 | - [Version Control Integration](#version-control-integration) 86 | - [Writing Tests](#writing-tests) 87 | - [Testing Components](#testing-components) 88 | - [Using Third Party Assertion Libraries](#using-third-party-assertion-libraries) 89 | - [Initializing Test Environment](#initializing-test-environment) 90 | - [Focusing and Excluding Tests](#focusing-and-excluding-tests) 91 | - [Coverage Reporting](#coverage-reporting) 92 | - [Continuous Integration](#continuous-integration) 93 | - [Disabling jsdom](#disabling-jsdom) 94 | - [Experimental Snapshot Testing](#experimental-snapshot-testing) 95 | - [Deployment](#deployment) 96 | - [Building for Relative Paths](#building-for-relative-paths) 97 | - [GitHub Pages](#github-pages) 98 | - [Heroku](#heroku) 99 | - [Modulus](#modulus) 100 | - [Netlify](#netlify) 101 | - [Now](#now) 102 | - [Surge](#surge) 103 | - [Something Missing?](#something-missing) 104 | 105 | ## Updating to New Releases 106 | 107 | Create React App is divided into two packages: 108 | 109 | * `create-react-app` is a global command-line utility that you use to create new projects. 110 | * `react-scripts` is a development dependency in the generated projects (including this one). 111 | 112 | You almost never need to update `create-react-app` itself: it delegates all the setup to `react-scripts`. 113 | 114 | When you run `create-react-app`, it always creates the project with the latest version of `react-scripts` so you’ll get all the new features and improvements in newly created apps automatically. 115 | 116 | To update an existing project to a new version of `react-scripts`, [open the changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md), find the version you’re currently on (check `package.json` in this folder if you’re not sure), and apply the migration instructions for the newer versions. 117 | 118 | In most cases bumping the `react-scripts` version in `package.json` and running `npm install` in this folder should be enough, but it’s good to consult the [changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md) for potential breaking changes. 119 | 120 | We commit to keeping the breaking changes minimal so you can upgrade `react-scripts` painlessly. 121 | 122 | ## Sending Feedback 123 | 124 | We are always open to [your feedback](https://github.com/facebookincubator/create-react-app/issues). 125 | 126 | ## Folder Structure 127 | 128 | After creation, your project should look like this: 129 | 130 | ``` 131 | my-app/ 132 | README.md 133 | node_modules/ 134 | package.json 135 | public/ 136 | index.html 137 | favicon.ico 138 | src/ 139 | App.css 140 | App.js 141 | App.test.js 142 | index.css 143 | index.js 144 | logo.svg 145 | ``` 146 | 147 | For the project to build, **these files must exist with exact filenames**: 148 | 149 | * `public/index.html` is the page template; 150 | * `src/index.js` is the JavaScript entry point. 151 | 152 | You can delete or rename the other files. 153 | 154 | You may create subdirectories inside `src`. For faster rebuilds, only files inside `src` are processed by Webpack.
155 | You need to **put any JS and CSS files inside `src`**, or Webpack won’t see them. 156 | 157 | Only files inside `public` can be used from `public/index.html`.
158 | Read instructions below for using assets from JavaScript and HTML. 159 | 160 | You can, however, create more top-level directories.
161 | They will not be included in the production build so you can use them for things like documentation. 162 | 163 | ## Available Scripts 164 | 165 | In the project directory, you can run: 166 | 167 | ### `npm start` 168 | 169 | Runs the app in the development mode.
170 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 171 | 172 | The page will reload if you make edits.
173 | You will also see any lint errors in the console. 174 | 175 | ### `npm test` 176 | 177 | Launches the test runner in the interactive watch mode.
178 | See the section about [running tests](#running-tests) for more information. 179 | 180 | ### `npm run build` 181 | 182 | Builds the app for production to the `build` folder.
183 | It correctly bundles React in production mode and optimizes the build for the best performance. 184 | 185 | The build is minified and the filenames include the hashes.
186 | Your app is ready to be deployed! 187 | 188 | ### `npm run eject` 189 | 190 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 191 | 192 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 193 | 194 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 195 | 196 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 197 | 198 | ## Displaying Lint Output in the Editor 199 | 200 | >Note: this feature is available with `react-scripts@0.2.0` and higher. 201 | 202 | Some editors, including Sublime Text, Atom, and Visual Studio Code, provide plugins for ESLint. 203 | 204 | They are not required for linting. You should see the linter output right in your terminal as well as the browser console. However, if you prefer the lint results to appear right in your editor, there are some extra steps you can do. 205 | 206 | You would need to install an ESLint plugin for your editor first. 207 | 208 | >**A note for Atom `linter-eslint` users** 209 | 210 | >If you are using the Atom `linter-eslint` plugin, make sure that **Use global ESLint installation** option is checked: 211 | 212 | > 213 | 214 | Then add this block to the `package.json` file of your project: 215 | 216 | ```js 217 | { 218 | // ... 219 | "eslintConfig": { 220 | "extends": "react-app" 221 | } 222 | } 223 | ``` 224 | 225 | Finally, you will need to install some packages *globally*: 226 | 227 | ```sh 228 | npm install -g eslint-config-react-app@0.3.0 eslint@3.8.1 babel-eslint@7.0.0 eslint-plugin-react@6.4.1 eslint-plugin-import@2.0.1 eslint-plugin-jsx-a11y@2.2.3 eslint-plugin-flowtype@2.21.0 229 | ``` 230 | 231 | We recognize that this is suboptimal, but it is currently required due to the way we hide the ESLint dependency. The ESLint team is already [working on a solution to this](https://github.com/eslint/eslint/issues/3458) so this may become unnecessary in a couple of months. 232 | 233 | ## Installing a Dependency 234 | 235 | The generated project includes React and ReactDOM as dependencies. It also includes a set of scripts used by Create React App as a development dependency. You may install other dependencies (for example, React Router) with `npm`: 236 | 237 | ``` 238 | npm install --save 239 | ``` 240 | 241 | ## Importing a Component 242 | 243 | This project setup supports ES6 modules thanks to Babel.
244 | While you can still use `require()` and `module.exports`, we encourage you to use [`import` and `export`](http://exploringjs.com/es6/ch_modules.html) instead. 245 | 246 | For example: 247 | 248 | ### `Button.js` 249 | 250 | ```js 251 | import React, { Component } from 'react'; 252 | 253 | class Button extends Component { 254 | render() { 255 | // ... 256 | } 257 | } 258 | 259 | export default Button; // Don’t forget to use export default! 260 | ``` 261 | 262 | ### `DangerButton.js` 263 | 264 | 265 | ```js 266 | import React, { Component } from 'react'; 267 | import Button from './Button'; // Import a component from another file 268 | 269 | class DangerButton extends Component { 270 | render() { 271 | return