Skip to content

Commit 054b0d9

Browse files
committed
# 158 on hooks. Review and updated from 00 to 03.
1 parent 297e898 commit 054b0d9

7 files changed

Lines changed: 19 additions & 18 deletions

File tree

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) => (

0 commit comments

Comments
 (0)