diff --git a/.gitignore b/.gitignore
index d922a11..d51fabd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,4 +6,5 @@ typings/
.idea/
*/src/**/*.js
*/src/**/*.js.map
-package-lock.json
\ No newline at end of file
+package-lock.json
+.vscode
diff --git a/hooks/00_BoilerPlate/Readme.md b/hooks/00_BoilerPlate/Readme.md
index 25d4324..d2b0180 100644
--- a/hooks/00_BoilerPlate/Readme.md
+++ b/hooks/00_BoilerPlate/Readme.md
@@ -22,7 +22,7 @@ Summary steps:
# Prerequisites
-Install [Node.js and npm](https://nodejs.org/en/) (v8.9.1) if they are not already installed on your computer.
+Install [Node.js and npm](https://nodejs.org/en/) (v8.9.1 or higher) if they are not already installed on your computer.
> 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.
diff --git a/hooks/01_HelloReact/Readme.md b/hooks/01_HelloReact/Readme.md
index e1e3f82..528987a 100644
--- a/hooks/01_HelloReact/Readme.md
+++ b/hooks/01_HelloReact/Readme.md
@@ -109,13 +109,13 @@ module.exports = {
resolve: {
extensions: ['.js', '.ts', '.tsx']
},
- entry: {
-- app: './index.ts',
-+ app: './index.tsx',
- vendorStyles: [
- '../node_modules/bootstrap/dist/css/bootstrap.css',
- ],
- },
+ entry: ["@babel/polyfill",
+ - "main.ts"],
+ + "./index.tsx"],
+ output: {
+ path: path.join(basePath, "dist"),
+ filename: "bundle.js"
+ },
```
- Execute the example:
diff --git a/hooks/02_Properties/Readme.md b/hooks/02_Properties/Readme.md
index aee5f3f..1fb6b19 100644
--- a/hooks/02_Properties/Readme.md
+++ b/hooks/02_Properties/Readme.md
@@ -13,7 +13,7 @@ We take as startup point the example **01 Hello React**:
## Prerequisites
-Install [Node.js and npm](https://nodejs.org/en/) (v6.6.0) if they are not already installed on your computer.
+Install [Node.js and npm](https://nodejs.org/en/) (v6.6.0 or higher) if they are not already installed on your computer.
> 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.
@@ -37,12 +37,13 @@ import * as React from 'react';
+ }
- export const HelloComponent = () => {
-+ export const HelloComponent = (props: Props) => {
- return (
++ export const HelloComponent = (props: Props) => (
+- {
+- return (
-
Hello component !
+ Hello user: { props.userName } !
);
-}
+- }
```
- Let's update _index.tsx_ and provide a value to the _userName_ property:
diff --git a/hooks/02_Properties/src/hello.tsx b/hooks/02_Properties/src/hello.tsx
index 33a0ab7..38df41c 100644
--- a/hooks/02_Properties/src/hello.tsx
+++ b/hooks/02_Properties/src/hello.tsx
@@ -4,6 +4,6 @@ interface Props {
userName: string;
}
-export const HelloComponent = (props: Props) => {
- return Hello user: {props.userName} !
;
-};
+export const HelloComponent = (props: Props) => (
+ Hello user: {props.userName} !
+);
\ No newline at end of file
diff --git a/hooks/03_State/Readme.md b/hooks/03_State/Readme.md
index 79ca23e..17c56cb 100644
--- a/hooks/03_State/Readme.md
+++ b/hooks/03_State/Readme.md
@@ -66,7 +66,7 @@ _./src/index.tsx_
```
- 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
- allow _App_ fucntional components to make use of state (this works in React 16.8.2 and above if you have to use
+ allow _App_ functional components to make use of state (this works in React 16.8.2 and above if you have to use
older verions you have to use a class component, check the "old*classes_components" on the root of this repo for example).
We will add \_userName* to the state.
diff --git a/hooks/03_State/src/app.tsx b/hooks/03_State/src/app.tsx
index 00523d1..f7d1429 100644
--- a/hooks/03_State/src/app.tsx
+++ b/hooks/03_State/src/app.tsx
@@ -3,7 +3,7 @@ import { HelloComponent } from "./hello";
import { NameEditComponent } from "./nameEdit";
export const App = () => {
- const [name, setName] = React.useState("defaultUserName");
+ const [name, setName] = React.useState("initialName");
const setUsernameState = (event: React.ChangeEvent) => {
setName(event.target.value);
diff --git a/hooks/03_State/src/nameEdit.tsx b/hooks/03_State/src/nameEdit.tsx
index f8691f7..09c4cd1 100644
--- a/hooks/03_State/src/nameEdit.tsx
+++ b/hooks/03_State/src/nameEdit.tsx
@@ -2,7 +2,7 @@ import * as React from "react";
interface Props {
userName: string;
- onChange: (e : React.ChangeEvent) => void;
+ onChange: (e: React.ChangeEvent) => void;
}
export const NameEditComponent = (props: Props) => (
diff --git a/old_class_components_samples/00 BoilerPlate/package.json b/old_class_components_samples/00 BoilerPlate/package.json
index 321c90b..cdee4b1 100644
--- a/old_class_components_samples/00 BoilerPlate/package.json
+++ b/old_class_components_samples/00 BoilerPlate/package.json
@@ -22,7 +22,7 @@
"typescript": "^2.8.3",
"url-loader": "^1.0.1",
"webpack": "^4.8.1",
- "webpack-cli": "^2.1.3",
+ "webpack-cli": "3.2.3",
"webpack-dev-server": "^3.1.4"
},
"dependencies": {
diff --git a/old_class_components_samples/00 BoilerPlate/readme.md b/old_class_components_samples/00 BoilerPlate/readme.md
index 7356ffb..e0b08c4 100644
--- a/old_class_components_samples/00 BoilerPlate/readme.md
+++ b/old_class_components_samples/00 BoilerPlate/readme.md
@@ -24,7 +24,7 @@ Summary steps:
# Prerequisites
-Install [Node.js and npm](https://nodejs.org/en/) (v8.9.4) if they are not already installed on your computer.
+Install at least [Node.js and npm](https://nodejs.org/en/) (v8.9.4) if they are not already installed on your computer.
> 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.
@@ -143,29 +143,32 @@ _[./package.json](./package.json)_
{
"name": "reactboilerplate",
"version": "1.0.0",
- "description": "Sample working with React,TypeScript and Webpack",
+ "description": "sample working with React, Typescript and Webpack",
+ "main": "index.js",
"scripts": {
- "start": "webpack-dev-server",
- "build": "webpack"
- },
- "author": "Lemoncode",
- "license": "MIT",
- "dependencies": {
- "bootstrap": "^3.3.7",
- "jquery": "^3.2.1"
+ "test": "echo \"Error: no test specified\" && exit 1",
+ "start": "webpack-dev-server --mode development --inline --hot --open",
+ "build": "webpack --mode development"
},
+ "author": "",
+ "license": "ISC",
"devDependencies": {
- "awesome-typescript-loader": "^3.1.3",
- "babel-core": "^6.25.0",
- "babel-preset-env": "^1.5.2",
- "css-loader": "^0.28.4",
- "file-loader": "^0.11.2",
- "html-webpack-plugin": "^2.28.0",
- "style-loader": "^0.18.2",
- "typescript": "^2.3.4",
- "url-loader": "^0.5.9",
- "webpack": "^2.6.1",
- "webpack-dev-server": "^2.4.5"
+ "awesome-typescript-loader": "^5.0.0",
+ "babel-core": "^6.26.3",
+ "babel-preset-env": "^1.7.0",
+ "css-loader": "^0.28.11",
+ "file-loader": "^1.1.11",
+ "html-webpack-plugin": "^3.2.0",
+ "mini-css-extract-plugin": "^0.4.0",
+ "style-loader": "^0.21.0",
+ "typescript": "^2.8.3",
+ "url-loader": "^1.0.1",
+ "webpack": "^4.8.1",
+ "webpack-cli": "^2.1.3",
+ "webpack-dev-server": "^3.1.4"
+ },
+ "dependencies": {
+ "bootstrap": "^4.1.1"
}
}
@@ -198,8 +201,7 @@ _[./src/index.html](./src/index.html)_
```
-- Now it's time to create a basic **[./webpack.config.js](./webpack.config.js)** file, this configuration will
- include plumbing for:
+- Now it's time to create a basic **[./webpack.config.js](./webpack.config.js)** file, this configuration will include plumbing for:
- Launching a web dev server.
- Transpiling from TypeScript to JavaScript.
- Setup Twitter Bootstrap (including fonts, etc...).
@@ -278,6 +280,7 @@ module.exports = {
```
npm start
```
+ ## Note: If you have problems when running the app you should update webpack-cli to : "webpack-cli": "3.2.3"
# About Lemoncode
diff --git a/old_class_components_samples/02 Components/readme.md b/old_class_components_samples/02 Components/readme.md
index 3299f11..83619aa 100644
--- a/old_class_components_samples/02 Components/readme.md
+++ b/old_class_components_samples/02 Components/readme.md
@@ -13,7 +13,7 @@ Summary steps:
## Prerequisites
-Install [Node.js and npm](https://nodejs.org/en/) (v6.6.0) if they are not already
+Install [Node.js and npm](https://nodejs.org/en/) (v6.6.0or higher) if they are not already
installed on your computer.
> Verify that you are running at least node v6.x.x and npm 3.x.x by running `node -v` and `npm -v`
diff --git a/old_class_components_samples/02 Components/src/components/about.tsx b/old_class_components_samples/02 Components/src/components/about.tsx
index 1e333c7..69ac59d 100644
--- a/old_class_components_samples/02 Components/src/components/about.tsx
+++ b/old_class_components_samples/02 Components/src/components/about.tsx
@@ -11,7 +11,7 @@ export const About: React.StatelessComponent<{}> = () => {
This sample takes the sample "01 Hello react" as starting point.
-
+
We are adding react components: a main component that consumes a header and an about component.
@@ -20,7 +20,7 @@ export const About: React.StatelessComponent<{}> = () => {
-
+
Highlights
@@ -30,7 +30,7 @@ export const About: React.StatelessComponent<{}> = () => {
-
+
-
Components:
diff --git a/old_class_components_samples/03 Navigation/package.json b/old_class_components_samples/03 Navigation/package.json
index 0de1df1..da757d1 100644
--- a/old_class_components_samples/03 Navigation/package.json
+++ b/old_class_components_samples/03 Navigation/package.json
@@ -9,6 +9,7 @@
"author": "Lemoncode",
"license": "MIT",
"dependencies": {
+ "@types/node": "^11.9.5",
"bootstrap": "^4.1.3",
"jquery": "^3.2.1",
"mini-css-extract-plugin": "^0.4.1",
diff --git a/old_class_components_samples/03 Navigation/readme.md b/old_class_components_samples/03 Navigation/readme.md
index 0079b46..dc60e00 100644
--- a/old_class_components_samples/03 Navigation/readme.md
+++ b/old_class_components_samples/03 Navigation/readme.md
@@ -20,7 +20,7 @@ Install [Node.js and npm](https://nodejs.org/en/) (v6.6.0) if they are not alrea
installed on your computer.
> 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.
+> in a terminal/console window. Older versions may produce errors.
## Steps to build it
@@ -28,20 +28,22 @@ in a terminal/console window. Older versions may produce errors.
- Install the npm packages described in the `package.json` and verify that it works:
- ```bash
- $ npm install
- ```
+```bash
+$ npm install
+```
- Install `react-router-dom` and typings:
```bash
npm install react-router-dom --save
npm install @types/react-router-dom --save-dev
+npm i @types/node
```
- Update `vendors`:
### ./webpack.config.js
+
```diff
...
entry: {
@@ -62,8 +64,9 @@ entry: {
- Now, we can start adding a dummy `Members Page`:
### ./src/components/members/page.tsx
+
```javascript
-import * as React from 'react';
+import * as React from "react";
export const MembersPage: React.StatelessComponent<{}> = () => {
return (
@@ -71,21 +74,21 @@ export const MembersPage: React.StatelessComponent<{}> = () => {
Members Page
);
-}
-
+};
```
- And its `index.ts` file:
### ./src/components/members/index.ts
-```javascript
-export * from './page';
+```javascript
+export * from "./page";
```
- Update `header` component to add links to navigate other pages:
### ./src/components/header.tsx
+
```diff
import * as React from 'react';
+ import { Link } from 'react-router-dom';
@@ -103,13 +106,12 @@ export const Header: React.StatelessComponent<{}> = () => {
+
+
@@ -121,6 +123,7 @@ export const Header: React.StatelessComponent<{}> = () => {
- Update components `index.ts` file:
### ./src/components/index.ts
+
```diff
export * from './header';
export * from './about';
@@ -133,11 +136,12 @@ export * from './about';
- Now, we are going to create the `AppRouter` component where we define routes:
### ./src/router.tsx
+
```javascript
- import * as React from 'react';
- import { Route, HashRouter, Switch } from 'react-router-dom';
- import { App } from './app';
- import { About, MembersPage } from './components';
+ import * as React from "react";
+ import { Route, HashRouter, Switch } from "react-router-dom";
+ import { App } from "./app";
+ import { About, MembersPage } from "./components";
export const AppRouter: React.StatelessComponent<{}> = () => {
return (
@@ -152,7 +156,7 @@ export * from './about';
);
- }
+ };
```
- The type of router that we are using is HashRouter because we are creating a static website.
@@ -163,6 +167,7 @@ export * from './about';
- Update `App`. We will remove the div enclosing `Header` because we have already added it in `AppRouter`:
### ./src/app.tsx
+
```diff
import * as React from 'react';
- import { Header, About } from './components';
@@ -183,6 +188,7 @@ import * as React from 'react';
- And finally, update main file:
### ./src/index.tsx
+
```diff
import * as React from 'react';
import * as ReactDOM from 'react-dom';
@@ -198,11 +204,11 @@ ReactDOM.render(
- Execute the example:
- ```bash
- $ npm start
- ```
+```bash
+$ npm start
+```
# About Lemoncode
We are a team of long-term experienced freelance developers, established as a group in 2010.
-We specialize in Front End technologies and .NET. [Click here](http://lemoncode.net/services/en/#en-home) to get more info about us.
+We specialize in Front End technologies and .NET. [Click here](http://lemoncode.net/services/en/#en-home) to get more info about us.
diff --git a/old_class_components_samples/03 Navigation/src/components/header.tsx b/old_class_components_samples/03 Navigation/src/components/header.tsx
index 3aeb58d..bf64b82 100644
--- a/old_class_components_samples/03 Navigation/src/components/header.tsx
+++ b/old_class_components_samples/03 Navigation/src/components/header.tsx
@@ -1,29 +1,49 @@
-import * as React from 'react';
-import { Link } from 'react-router-dom';
+import * as React from "react";
+import { Link } from "react-router-dom";
export const Header: React.StatelessComponent<{}> = () => {
return (
);
-}
\ No newline at end of file
+};