Skip to content

Commit e7910d4

Browse files
authored
Merge pull request #2 from Lemoncode/master
Merge from original repo
2 parents 5bcbaaf + 4a7e741 commit e7910d4

129 files changed

Lines changed: 5036 additions & 110 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.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: 15 additions & 10 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:
@@ -124,7 +124,12 @@ module.exports = {
124124
npm start
125125
```
126126

127-
# About Lemoncode
127+
# About Basefactor + Lemoncode
128+
129+
We are an innovating team of Javascript experts, passionate about turning your ideas into robust products.
130+
131+
[Basefactor, consultancy by Lemoncode](http://www.basefactor.com) provides consultancy and coaching services.
132+
133+
[Lemoncode](http://lemoncode.net/services/en/#en-home) provides training services.
128134

129-
We are a team of long-term experienced freelance developers, established as a group in 2010.
130-
We specialize in Front End technologies and .NET. [Click here](http://lemoncode.net/services/en/#en-home) to get more info about us.
135+
For the LATAM/Spanish audience we are running an Online Front End Master degree, more info: http://lemoncode.net/master-frontend

hooks/02_Properties/Readme.md

Lines changed: 16 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:
@@ -66,3 +67,14 @@ _./src/index.tsx_
6667
```cmd
6768
npm start
6869
```
70+
71+
# About Basefactor + Lemoncode
72+
73+
We are an innovating team of Javascript experts, passionate about turning your ideas into robust products.
74+
75+
[Basefactor, consultancy by Lemoncode](http://www.basefactor.com) provides consultancy and coaching services.
76+
77+
[Lemoncode](http://lemoncode.net/services/en/#en-home) provides training services.
78+
79+
For the LATAM/Spanish audience we are running an Online Front End Master degree, more info: http://lemoncode.net/master-frontend
80+

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: 12 additions & 3 deletions
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

@@ -154,10 +154,19 @@ export const App = () => {
154154
};
155155
```
156156

157-
Side note: mind the use of the fat arrow function. This avoids losing the context for _this_ in the callback.
158-
159157
- Finally let's test everything works once more.
160158

161159
```
162160
npm start
163161
```
162+
163+
# About Basefactor + Lemoncode
164+
165+
We are an innovating team of Javascript experts, passionate about turning your ideas into robust products.
166+
167+
[Basefactor, consultancy by Lemoncode](http://www.basefactor.com) provides consultancy and coaching services.
168+
169+
[Lemoncode](http://lemoncode.net/services/en/#en-home) provides training services.
170+
171+
For the LATAM/Spanish audience we are running an Online Front End Master degree, more info: http://lemoncode.net/master-frontend
172+

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

hooks/04_Callback/Readme.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,14 @@ Now we've got a clear event, strongly typed and simplified (as it is more straig
110110
Now, the greetings message only changes when the user clicks the change button.
111111

112112
> What happens if we simulate an AJAX call? Let's place in the app's componentWillMount a timeout and set the name value in the timeout's callback.
113+
114+
# About Basefactor + Lemoncode
115+
116+
We are an innovating team of Javascript experts, passionate about turning your ideas into robust products.
117+
118+
[Basefactor, consultancy by Lemoncode](http://www.basefactor.com) provides consultancy and coaching services.
119+
120+
[Lemoncode](http://lemoncode.net/services/en/#en-home) provides training services.
121+
122+
For the LATAM/Spanish audience we are running an Online Front End Master degree, more info: http://lemoncode.net/master-frontend
123+

hooks/05_Refactor/Readme.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,57 @@ export const App = () => {
162162
);
163163
};
164164
```
165+
166+
- Now let's jump into _NameEditComponent_ and update the contract and
167+
implementation:
168+
169+
```diff
170+
interface Props {
171+
initialUserName: string;
172+
+ editingName: string;
173+
- onNameUpdated: (newName: string) => any;
174+
+ onNameUpdated: () => any;
175+
+ onEditingNameUpdated: (newEditingName: string) => any;
176+
}
177+
```
178+
179+
```diff
180+
export const NameEditComponent = (props: Props) => {
181+
- const [editingName, setEditingName] = React.useState(props.initialUserName);
182+
183+
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
184+
- setEditingName(e.target.value);
185+
+ props.onEditingNameUpdated(e.target.value);
186+
};
187+
188+
const onNameSubmit = (event: any): any => {
189+
- props.onNameUpdated(editingName);
190+
+ props.onNameUpdated();
191+
};
192+
193+
- if(props.initialUserName !== lastInitialName) {
194+
- setLastInitialName(props.initialUserName);
195+
- setEditingName(props.initialUserName);
196+
- }
197+
198+
199+
return (
200+
<>
201+
<label>Update name:</label>
202+
- <input value={editingName} onChange={onChange} />
203+
+ <input value={props.editingName} onChange={onChange} />
204+
<button onClick={onNameSubmit}>Change</button>
205+
</>
206+
);
207+
};
208+
```
209+
210+
# About Basefactor + Lemoncode
211+
212+
We are an innovating team of Javascript experts, passionate about turning your ideas into robust products.
213+
214+
[Basefactor, consultancy by Lemoncode](http://www.basefactor.com) provides consultancy and coaching services.
215+
216+
[Lemoncode](http://lemoncode.net/services/en/#en-home) provides training services.
217+
218+
For the LATAM/Spanish audience we are running an Online Front End Master degree, more info: http://lemoncode.net/master-frontend

0 commit comments

Comments
 (0)