GeezerVison is showing github.com — Localizes Samples & Updates JSBin Links (#16) · cpchrispack/learning-react@270bfbd
File treeExpand file treeCollapse file tree Open diff view settings 02-imperative-vs-declarative 07-higher-order-functions
01-property-validation-and-default-props
05-higher-order-components 06-managing-state-outside-react
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: chapter-01/readme.md +21-7Lines changed: 21 additions & 7 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -53,9 +53,8 @@ optionally install one of these version mangers: | 53 | 53 |
| 54 | 54 | Installing the React Tools | 55 | 55 | -------------------------------- | 56 | | -Next, there are some Chrome developer extensions or Firefox add-ons that you will need to install in order to debug React: | | 56 | +Next, install the React developer tools: | 57 | 57 |
| 58 | | -* Detector ([Chrome](https://chrome.google.com/webstore/detail/react-detector/jaaklebbenondhkanegppccanebkdjlh?hl=en-US)) | 59 | 58 | * Development Tools ([Chrome](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en) | | 60 | 59 | [Firefox](https://addons.mozilla.org/en-US/firefox/addon/react-devtools/)) | 61 | 60 |
| @@ -64,8 +63,23 @@ Working with JSBin | 64 | 63 | This repository links to samples hosted on JSBin so that you can immediately begin changing each sample and checking | 65 | 64 | output to see how each sample has changed. | 66 | 65 |
| 67 | | -Here is a Hello World sample that JSBin has assigned the identifier __gosabo__. There are 3 available versions of this | 68 | | -sample in JSBin under the same identifier. | | 66 | +Here is a Hello World sample that JSBin has assigned the identifier __gosabo__. There are 3 available versions of this sample in JSBin under the same identifier. | | 67 | + | | 68 | +Note: All JSBin links throughout this repository use React 15. To update, change the script tag CDN links to version 16. | | 69 | + | | 70 | +Change | | 71 | + | | 72 | +```html | | 73 | + <script src="https://fb.me/react-with-addons-15.1.0.js"></script> | | 74 | + <script src="https://fb.me/react-dom-15.1.0.js"></script> | | 75 | +``` | | 76 | + | | 77 | +To | | 78 | + | | 79 | +```html | | 80 | + <script src="https://unpkg.com/react@16/umd/react.development.js"></script> | | 81 | + <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script> | | 82 | +``` | 69 | 83 |
| 70 | 84 | ##### A preview of the latest version in a sample: | 71 | 85 | [http://output.jsbin.com/gosabo](http://output.jsbin.com/gosabo) | @@ -89,9 +103,9 @@ CDN's for JavaScript libraries | 89 | 103 | Ultimately, we will be working with webpack and npms, but to get running quickly, here are some CDN links that | 90 | 104 | can be included in JSBin with this syntax: `<script src="https://[CDN LINK]"></script>` | 91 | 105 |
| 92 | | -* [React](https://unpkg.com/react@15.4.2/dist/react.js) | 93 | | -* [React DOM](https://unpkg.com/react-dom@15.4.2/dist/react-dom.js) | 94 | | -* [Babel Inline Transpiller](https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.js) | | 106 | +* [React](https://unpkg.com/react@16/umd/react.development.js) | | 107 | +* [React DOM](https://unpkg.com/react-dom@16/umd/react-dom.development.js) | | 108 | + | 95 | 109 | * [fetch](https://cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js) | 96 | 110 | * [Redux](https://cdnjs.cloudflare.com/ajax/libs/redux/3.6.0/redux.min.js) | 97 | 111 | * [React Router Source](https://cdnjs.cloudflare.com/ajax/libs/react-router/4.0.0/react-router.min.js) | |
Collapse file Copy file name to clipboard +22Lines changed: 22 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<!DOCTYPE html> | | 2 | +<html> | | 3 | +<head> | | 4 | + <meta name="viewport" content="minimum-scale=1.0, width=device-width, maximum-scale=1.0, user-scalable=no"/> | | 5 | + <meta charset="utf-8"> | | 6 | + <title>Const</title> | | 7 | + | | 8 | +</head> | | 9 | +<body> | | 10 | +<h1>Const</h1> | | 11 | +<p>Open the console</p> | | 12 | +<script type="text/babel"> | | 13 | + | | 14 | + // The value of a variable can change | | 15 | + | | 16 | + var pizza = true | | 17 | + pizza = false | | 18 | + console.log(pizza) | | 19 | + | | 20 | +</script> | | 21 | +</body> | | 22 | +</html> |
Collapse file Copy file name to clipboard +21Lines changed: 21 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<!DOCTYPE html> | | 2 | +<html> | | 3 | +<head> | | 4 | + <meta name="viewport" content="minimum-scale=1.0, width=device-width, maximum-scale=1.0, user-scalable=no"/> | | 5 | + <meta charset="utf-8"> | | 6 | + <title>Const</title> | | 7 | + | | 8 | +</head> | | 9 | +<body> | | 10 | +<h1>Const</h1> | | 11 | +<p>Open the console</p> | | 12 | +<script type="text/babel"> | | 13 | + | | 14 | + // ES6 introduces constants | | 15 | + | | 16 | + const pizza = true | | 17 | + pizza = false | | 18 | + | | 19 | +</script> | | 20 | +</body> | | 21 | +</html> |
Collapse file Copy file name to clipboard +27Lines changed: 27 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<!DOCTYPE html> | | 2 | +<html> | | 3 | +<head> | | 4 | + <meta name="viewport" content="minimum-scale=1.0, width=device-width, maximum-scale=1.0, user-scalable=no"/> | | 5 | + <meta charset="utf-8"> | | 6 | + <title>Let</title> | | 7 | + | | 8 | +</head> | | 9 | +<body> | | 10 | +<h1>Let</h1> | | 11 | +<p>Open the console</p> | | 12 | +<script type="text/babel"> | | 13 | + | | 14 | + // Variables cannot be scoped to code blocks | | 15 | + | | 16 | + var topic = "JavaScript" | | 17 | + | | 18 | + if (topic) { | | 19 | + var topic = "React" | | 20 | + console.log('block', topic) | | 21 | + } | | 22 | + | | 23 | + console.log('global', topic) | | 24 | + | | 25 | +</script> | | 26 | +</body> | | 27 | +</html> |
Collapse file Copy file name to clipboard +27Lines changed: 27 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<!DOCTYPE html> | | 2 | +<html> | | 3 | +<head> | | 4 | + <meta name="viewport" content="minimum-scale=1.0, width=device-width, maximum-scale=1.0, user-scalable=no"/> | | 5 | + <meta charset="utf-8"> | | 6 | + <title>Let</title> | | 7 | + | | 8 | +</head> | | 9 | +<body> | | 10 | +<h1>Let</h1> | | 11 | +<p>Open the console</p> | | 12 | +<script type="text/babel"> | | 13 | + | | 14 | + // ES6 lexical variable scoping with let | | 15 | + | | 16 | + var topic = "JavaScript" | | 17 | + | | 18 | + if (topic) { | | 19 | + let topic = "React" | | 20 | + console.log('block', topic) | | 21 | + } | | 22 | + | | 23 | + console.log('global', topic) | | 24 | + | | 25 | +</script> | | 26 | +</body> | | 27 | +</html> |
Collapse file Copy file name to clipboard +41Lines changed: 41 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<!DOCTYPE html> | | 2 | +<html> | | 3 | +<head> | | 4 | + <meta name="viewport" content="minimum-scale=1.0, width=device-width, maximum-scale=1.0, user-scalable=no"/> | | 5 | + <meta charset="utf-8"> | | 6 | + <style media="screen"> | | 7 | + #container { | | 8 | + display: flex; | | 9 | + justify-content: space-around; | | 10 | + } | | 11 | + | | 12 | + #container>div { | | 13 | + height: 5em; | | 14 | + width: 5em; | | 15 | + background-color: purple; | | 16 | + } | | 17 | + </style> | | 18 | + <title>Let</title> | | 19 | + | | 20 | +</head> | | 21 | +<body> | | 22 | + <h1>Click on a Box</h1> | | 23 | + <div id="container"></div> | | 24 | +<script type="text/babel"> | | 25 | + | | 26 | + // Problem, counters are not scoped to for loop blocks | | 27 | + | | 28 | + var div, | | 29 | + container = document.getElementById('container') | | 30 | + | | 31 | + for (var i=0; i<5; i++) { | | 32 | + div = document.createElement('div') | | 33 | + div.onclick = function() { | | 34 | + alert('This is box #' + i) | | 35 | + } | | 36 | + container.appendChild(div) | | 37 | + } | | 38 | + | | 39 | +</script> | | 40 | +</body> | | 41 | +</html> |
Collapse file Copy file name to clipboard +42Lines changed: 42 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<!DOCTYPE html> | | 2 | +<html> | | 3 | +<head> | | 4 | + <meta name="viewport" content="minimum-scale=1.0, width=device-width, maximum-scale=1.0, user-scalable=no"/> | | 5 | + <meta charset="utf-8"> | | 6 | + <style media="screen"> | | 7 | + #container { | | 8 | + display: flex; | | 9 | + justify-content: space-around; | | 10 | + } | | 11 | + | | 12 | + #container>div { | | 13 | + height: 5em; | | 14 | + width: 5em; | | 15 | + background-color: purple; | | 16 | + } | | 17 | + </style> | | 18 | + <title>Let</title> | | 19 | + | | 20 | +</head> | | 21 | +<body> | | 22 | + <h1>Click on a Box</h1> | | 23 | + <div id="container"></div> | | 24 | + | | 25 | +<script type="text/babel"> | | 26 | + | | 27 | + // Solution, lexical variable scope | | 28 | + | | 29 | + var div, | | 30 | + container = document.getElementById('container') | | 31 | + | | 32 | + for (let i=0; i<5; i++) { | | 33 | + div = document.createElement('div') | | 34 | + div.onclick = function() { | | 35 | + alert('This is box #' + i) | | 36 | + } | | 37 | + container.appendChild(div) | | 38 | + } | | 39 | + | | 40 | +</script> | | 41 | +</body> | | 42 | +</html> |
Collapse file Copy file name to clipboard +24Lines changed: 24 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<!DOCTYPE html> | | 2 | +<html> | | 3 | +<head> | | 4 | + <meta name="viewport" content="minimum-scale=1.0, width=device-width, maximum-scale=1.0, user-scalable=no"/> | | 5 | + <meta charset="utf-8"> | | 6 | + <title>Template Strings</title> | | 7 | + | | 8 | +</head> | | 9 | +<body> | | 10 | +<h1>Template Strings</h1> | | 11 | +<p>Open the console</p> | | 12 | +<script type="text/babel"> | | 13 | + | | 14 | + const lastName = "Ferrell" | | 15 | + const middleName = "William" | | 16 | + const firstName = "John" | | 17 | + | | 18 | + // string concatenation | | 19 | + | | 20 | + console.log(lastName + ", " + firstName + " " + middleName) | | 21 | + | | 22 | +</script> | | 23 | +</body> | | 24 | +</html> |
Collapse file Copy file name to clipboard +24Lines changed: 24 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<!DOCTYPE html> | | 2 | +<html> | | 3 | +<head> | | 4 | + <meta name="viewport" content="minimum-scale=1.0, width=device-width, maximum-scale=1.0, user-scalable=no"/> | | 5 | + <meta charset="utf-8"> | | 6 | + <title>Template Strings</title> | | 7 | + | | 8 | +</head> | | 9 | +<body> | | 10 | +<h1>Template Strings</h1> | | 11 | +<p>Open the console</p> | | 12 | +<script type="text/babel"> | | 13 | + | | 14 | + const lastName = "Ferrell" | | 15 | + const middleName = "William" | | 16 | + const firstName = "John" | | 17 | + | | 18 | + // ES6 template strings | | 19 | + | | 20 | + console.log(`${lastName}, ${firstName} ${middleName}`) | | 21 | + | | 22 | +</script> | | 23 | +</body> | | 24 | +</html> |
Collapse file Copy file name to clipboard +46Lines changed: 46 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +<!DOCTYPE html> | | 2 | +<html> | | 3 | +<head> | | 4 | + <meta name="viewport" content="minimum-scale=1.0, width=device-width, maximum-scale=1.0, user-scalable=no"/> | | 5 | + <meta charset="utf-8"> | | 6 | + <title>Template Strings</title> | | 7 | + | | 8 | +</head> | | 9 | +<body> | | 10 | +<h1>Template Strings</h1> | | 11 | +<p>Open the console</p> | | 12 | +<script type="text/babel"> | | 13 | + | | 14 | + var lastName = "Ferrell" | | 15 | + var middleName = "William" | | 16 | + var firstName = "John" | | 17 | + | | 18 | + var ticketAgent = "The iO Theater" | | 19 | + var event = "TJ & Dave" | | 20 | + var qty = 2 | | 21 | + var price = 10 | | 22 | + | | 23 | + // ES6 template strings do not ignore whitespace | | 24 | + | | 25 | + console.log(` | | 26 | +
| | 27 | + Hello ${firstName}, | | 28 | +
| | 29 | + Thanks for ordering ${qty} tickets to ${event}. | | 30 | +
| | 31 | + Order Details | | 32 | + ${firstName} ${middleName} ${lastName} | | 33 | + ${qty} x $${price} = $${qty*price} to ${event} | | 34 | +
| | 35 | + You can pick your tickets up at will call 30 minutes before | | 36 | + the show. | | 37 | +
| | 38 | + Thanks, | | 39 | +
| | 40 | + ${ticketAgent} | | 41 | +
| | 42 | + `) | | 43 | + | | 44 | +</script> | | 45 | +</body> | | 46 | +</html> |
|