Skip to content

Commit faa150a

Browse files
authored
Merge pull request #170 from dailymp/master
#158 Issue resolved
2 parents 5f00756 + 054b0d9 commit faa150a

15 files changed

Lines changed: 111 additions & 79 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ typings/
66
.idea/
77
*/src/**/*.js
88
*/src/**/*.js.map
9-
package-lock.json
9+
package-lock.json
10+
.vscode

hooks/00_BoilerPlate/Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Summary steps:
2222

2323
# Prerequisites
2424

25-
Install [Node.js and npm](https://nodejs.org/en/) (v8.9.1) if they are not already installed on your computer.
25+
Install [Node.js and npm](https://nodejs.org/en/) (v8.9.1 or higher) if they are not already installed on your computer.
2626

2727
> Verify that you are running at least node v8.x.x and npm 5.x.x by running `node -v` and `npm -v` in a terminal/console window. Older versions may produce errors.
2828

hooks/01_HelloReact/Readme.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ module.exports = {
109109
resolve: {
110110
extensions: ['.js', '.ts', '.tsx']
111111
},
112-
entry: {
113-
- app: './index.ts',
114-
+ app: './index.tsx',
115-
vendorStyles: [
116-
'../node_modules/bootstrap/dist/css/bootstrap.css',
117-
],
118-
},
112+
entry: ["@babel/polyfill",
113+
- "main.ts"],
114+
+ "./index.tsx"],
115+
output: {
116+
path: path.join(basePath, "dist"),
117+
filename: "bundle.js"
118+
},
119119
```
120120

121121
- Execute the example:

hooks/02_Properties/Readme.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ We take as startup point the example **01 Hello React**:
1313

1414
## Prerequisites
1515

16-
Install [Node.js and npm](https://nodejs.org/en/) (v6.6.0) if they are not already installed on your computer.
16+
Install [Node.js and npm](https://nodejs.org/en/) (v6.6.0 or higher) if they are not already installed on your computer.
1717

1818
> Verify that you are running at least node v6.x.x and npm 3.x.x by running `node -v` and `npm -v` in a terminal/console window. Older versions may produce errors.
1919
@@ -37,12 +37,13 @@ import * as React from 'react';
3737
+ }
3838

3939
- export const HelloComponent = () => {
40-
+ export const HelloComponent = (props: Props) => {
41-
return (
40+
+ export const HelloComponent = (props: Props) => (
41+
- {
42+
- return (
4243
- <h2>Hello component !</h2>
4344
+ <h2>Hello user: { props.userName } !</h2>
4445
);
45-
}
46+
- }
4647
```
4748

4849
- Let's update _index.tsx_ and provide a value to the _userName_ property:

hooks/02_Properties/src/hello.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ interface Props {
44
userName: string;
55
}
66

7-
export const HelloComponent = (props: Props) => {
8-
return <h2>Hello user: {props.userName} !</h2>;
9-
};
7+
export const HelloComponent = (props: Props) => (
8+
<h2>Hello user: {props.userName} !</h2>
9+
);

hooks/03_State/Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ _./src/index.tsx_
6666
```
6767

6868
- It's time to revisit _app.tsx_. We want to store the user's name and let the user updated it. We will use hooks to
69-
allow _App_ fucntional components to make use of state (this works in React 16.8.2 and above if you have to use
69+
allow _App_ functional components to make use of state (this works in React 16.8.2 and above if you have to use
7070
older verions you have to use a class component, check the "old*classes_components" on the root of this repo for example).
7171
We will add \_userName* to the state.
7272

hooks/03_State/src/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { HelloComponent } from "./hello";
33
import { NameEditComponent } from "./nameEdit";
44

55
export const App = () => {
6-
const [name, setName] = React.useState("defaultUserName");
6+
const [name, setName] = React.useState("initialName");
77

88
const setUsernameState = (event: React.ChangeEvent<HTMLInputElement>) => {
99
setName(event.target.value);

hooks/03_State/src/nameEdit.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from "react";
22

33
interface Props {
44
userName: string;
5-
onChange: (e : React.ChangeEvent<HTMLInputElement>) => void;
5+
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
66
}
77

88
export const NameEditComponent = (props: Props) => (

old_class_components_samples/00 BoilerPlate/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"typescript": "^2.8.3",
2323
"url-loader": "^1.0.1",
2424
"webpack": "^4.8.1",
25-
"webpack-cli": "^2.1.3",
25+
"webpack-cli": "3.2.3",
2626
"webpack-dev-server": "^3.1.4"
2727
},
2828
"dependencies": {

old_class_components_samples/00 BoilerPlate/readme.md

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Summary steps:
2424

2525
# Prerequisites
2626

27-
Install [Node.js and npm](https://nodejs.org/en/) (v8.9.4) if they are not already installed on your computer.
27+
Install at least [Node.js and npm](https://nodejs.org/en/) (v8.9.4) if they are not already installed on your computer.
2828

2929
> Verify that you are running at least node v8.x.x and npm 5.x.x by running `node -v` and `npm -v` in a terminal/console window. Older versions may produce errors.
3030
@@ -143,29 +143,32 @@ _[./package.json](./package.json)_
143143
{
144144
"name": "reactboilerplate",
145145
"version": "1.0.0",
146-
"description": "Sample working with React,TypeScript and Webpack",
146+
"description": "sample working with React, Typescript and Webpack",
147+
"main": "index.js",
147148
"scripts": {
148-
"start": "webpack-dev-server",
149-
"build": "webpack"
150-
},
151-
"author": "Lemoncode",
152-
"license": "MIT",
153-
"dependencies": {
154-
"bootstrap": "^3.3.7",
155-
"jquery": "^3.2.1"
149+
"test": "echo \"Error: no test specified\" && exit 1",
150+
"start": "webpack-dev-server --mode development --inline --hot --open",
151+
"build": "webpack --mode development"
156152
},
153+
"author": "",
154+
"license": "ISC",
157155
"devDependencies": {
158-
"awesome-typescript-loader": "^3.1.3",
159-
"babel-core": "^6.25.0",
160-
"babel-preset-env": "^1.5.2",
161-
"css-loader": "^0.28.4",
162-
"file-loader": "^0.11.2",
163-
"html-webpack-plugin": "^2.28.0",
164-
"style-loader": "^0.18.2",
165-
"typescript": "^2.3.4",
166-
"url-loader": "^0.5.9",
167-
"webpack": "^2.6.1",
168-
"webpack-dev-server": "^2.4.5"
156+
"awesome-typescript-loader": "^5.0.0",
157+
"babel-core": "^6.26.3",
158+
"babel-preset-env": "^1.7.0",
159+
"css-loader": "^0.28.11",
160+
"file-loader": "^1.1.11",
161+
"html-webpack-plugin": "^3.2.0",
162+
"mini-css-extract-plugin": "^0.4.0",
163+
"style-loader": "^0.21.0",
164+
"typescript": "^2.8.3",
165+
"url-loader": "^1.0.1",
166+
"webpack": "^4.8.1",
167+
"webpack-cli": "^2.1.3",
168+
"webpack-dev-server": "^3.1.4"
169+
},
170+
"dependencies": {
171+
"bootstrap": "^4.1.1"
169172
}
170173
}
171174

@@ -198,8 +201,7 @@ _[./src/index.html](./src/index.html)_
198201

199202
```
200203

201-
- Now it's time to create a basic **[./webpack.config.js](./webpack.config.js)** file, this configuration will
202-
include plumbing for:
204+
- Now it's time to create a basic **[./webpack.config.js](./webpack.config.js)** file, this configuration will include plumbing for:
203205
- Launching a web dev server.
204206
- Transpiling from TypeScript to JavaScript.
205207
- Setup Twitter Bootstrap (including fonts, etc...).
@@ -278,6 +280,7 @@ module.exports = {
278280
```
279281
npm start
280282
```
283+
## Note: If you have problems when running the app you should update webpack-cli to : "webpack-cli": "3.2.3"
281284

282285
# About Lemoncode
283286

0 commit comments

Comments
 (0)