diff --git a/04-frameworks/01-react/03-react-hooks/05-component-update-render/src/index.html b/04-frameworks/01-react/03-react-hooks/05-component-update-render/src/index.html
deleted file mode 100644
index a3d74b719..000000000
--- a/04-frameworks/01-react/03-react-hooks/05-component-update-render/src/index.html
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
My App Example
-
-
-
-
-
diff --git a/04-frameworks/01-react/03-react-hooks/05-component-update-render/tsconfig.json b/04-frameworks/01-react/03-react-hooks/05-component-update-render/tsconfig.json
index 3312b5f1e..a057cea1d 100644
--- a/04-frameworks/01-react/03-react-hooks/05-component-update-render/tsconfig.json
+++ b/04-frameworks/01-react/03-react-hooks/05-component-update-render/tsconfig.json
@@ -1,18 +1,19 @@
{
"compilerOptions": {
- "target": "es6",
- "module": "es6",
- "moduleResolution": "node",
- "declaration": false,
+ "esModuleInterop": true,
+ "isolatedModules": true,
+ "jsx": "react-jsx",
+ "lib": ["ESNext", "DOM"],
+ "module": "ESNext",
+ "moduleResolution": "bundler",
+ "noEmit": true,
"noImplicitAny": false,
- "allowSyntheticDefaultImports": true,
- "sourceMap": true,
- "jsx": "react",
- "noLib": false,
- "suppressImplicitAnyIndexErrors": true,
+ "noImplicitReturns": true,
+ "resolveJsonModule": true,
"skipLibCheck": true,
- "esModuleInterop": true
+ "sourceMap": true,
+ "target": "ESNext",
+ "useDefineForClassFields": true
},
- "include": ["src/**/*"],
- "exclude": ["node_modules"]
+ "include": ["src"]
}
diff --git a/04-frameworks/01-react/03-react-hooks/05-component-update-render/vite.config.ts b/04-frameworks/01-react/03-react-hooks/05-component-update-render/vite.config.ts
new file mode 100644
index 000000000..a0024d88e
--- /dev/null
+++ b/04-frameworks/01-react/03-react-hooks/05-component-update-render/vite.config.ts
@@ -0,0 +1,7 @@
+import { defineConfig } from "vite";
+import checker from "vite-plugin-checker";
+import react from "@vitejs/plugin-react";
+
+export default defineConfig({
+ plugins: [checker({ typescript: true }), react()],
+});
diff --git a/04-frameworks/01-react/03-react-hooks/05-component-update-render/webpack.config.js b/04-frameworks/01-react/03-react-hooks/05-component-update-render/webpack.config.js
deleted file mode 100644
index 326060f82..000000000
--- a/04-frameworks/01-react/03-react-hooks/05-component-update-render/webpack.config.js
+++ /dev/null
@@ -1,54 +0,0 @@
-const HtmlWebpackPlugin = require("html-webpack-plugin");
-const path = require("path");
-const basePath = __dirname;
-
-module.exports = {
- context: path.join(basePath, "src"),
- resolve: {
- extensions: [".js", ".ts", ".tsx"],
- },
- entry: {
- app: ["./index.tsx", "./styles.css"],
- },
- devtool: "eval-source-map",
- stats: "errors-only",
- output: {
- filename: "[name].[chunkhash].js",
- },
- module: {
- rules: [
- {
- test: /\.tsx?$/,
- exclude: /node_modules/,
- loader: "babel-loader",
- },
- {
- test: /\.(png|jpg)$/,
- type: "asset/resource",
- },
- {
- test: /\.html$/,
- loader: "html-loader",
- },
- {
- test: /\.css$/,
- exclude: /node_modules/,
- use: [
- {
- loader: "style-loader",
- },
- {
- loader: "css-loader",
- },
- ],
- },
- ],
- },
- plugins: [
- //Generate index.html in /dist => https://github.com/ampedandwired/html-webpack-plugin
- new HtmlWebpackPlugin({
- filename: "index.html", //Name of file in ./dist/
- template: "index.html", //Name of template in ./src
- }),
- ],
-};
diff --git a/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/.babelrc b/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/.babelrc
deleted file mode 100644
index 469d3d55f..000000000
--- a/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/.babelrc
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "presets": [
- "@babel/preset-env",
- "@babel/preset-typescript",
- "@babel/preset-react"
- ]
-}
diff --git a/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/Readme.md b/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/Readme.md
index b7789b8e5..27078f513 100644
--- a/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/Readme.md
+++ b/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/Readme.md
@@ -1,6 +1,6 @@
# 06 Ajax field change
-## Resume
+## Summary
This example takes as a starting point the example \ \_05-component-update-render.
@@ -16,7 +16,7 @@ As a bonus, we will check how to use Debounce (wait a little until the user stop
npm install
```
-- Let's open the _demo.js_, and let's add an entry in the state that stores the current search filter, and another state in which we
+- Let's open the _demo.tsx_, and let's add an entry in the state that stores the current search filter, and another state in which we
are going to store a list of users.
_./src/demo.tsx_
diff --git a/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/Readme_es.md b/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/Readme_es.md
index 6e0d253f3..4fecef354 100644
--- a/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/Readme_es.md
+++ b/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/Readme_es.md
@@ -21,7 +21,7 @@ así llamadas innecesarias).
npm install
```
-- Vamos abrir el fichero _demo.js_ y vamos añadir una entrada en el
+- Vamos abrir el fichero _demo.tsx_ y vamos añadir una entrada en el
estado que almacene el filtro actual de busqueda, y otra en la que almacene
una lista de usuarios.
diff --git a/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/index.html b/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/index.html
new file mode 100644
index 000000000..fe100be04
--- /dev/null
+++ b/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/index.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+
React App - React hooks
+
+
+
+
+
+
+
diff --git a/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/package.json b/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/package.json
index d434b896c..cb10a2306 100644
--- a/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/package.json
+++ b/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/package.json
@@ -1,40 +1,24 @@
{
- "name": "react-example",
- "version": "1.0.0",
- "description": "",
- "main": "index.js",
+ "name": "hello-vite",
+ "private": true,
+ "version": "0.0.0",
+ "type": "module",
"scripts": {
- "start": "run-p -l type-check:watch start:dev",
- "type-check": "tsc --noEmit",
- "type-check:watch": "npm run type-check -- --watch",
- "start:dev": "webpack-dev-server --mode development --open",
- "build": "rimraf dist && webpack --mode development"
+ "start": "vite --host",
+ "build": "vite build",
+ "preview": "vite preview"
},
- "author": "",
- "license": "ISC",
"devDependencies": {
- "@babel/cli": "^7.17.10",
- "@babel/core": "^7.17.10",
- "@babel/preset-env": "^7.17.10",
- "@babel/preset-react": "^7.17.12",
- "@babel/preset-typescript": "^7.16.7",
- "@types/react": "^18.0.9",
- "@types/react-dom": "^18.0.4",
- "babel-loader": "^8.2.5",
- "css-loader": "^6.7.1",
- "html-loader": "^3.1.0",
- "html-webpack-plugin": "^5.5.0",
- "npm-run-all": "^4.1.5",
- "rimraf": "^3.0.2",
- "style-loader": "^3.3.1",
- "typescript": "^4.6.4",
- "webpack": "^5.72.1",
- "webpack-cli": "^4.9.2",
- "webpack-dev-server": "^4.9.0"
+ "@types/react": "^19.1.8",
+ "@types/react-dom": "^19.1.6",
+ "@vitejs/plugin-react": "^4.6.0",
+ "typescript": "^5.8.3",
+ "vite": "^7.0.4",
+ "vite-plugin-checker": "^0.10.0"
},
"dependencies": {
- "react": "^18.1.0",
- "react-dom": "^18.1.0",
- "use-debounce": "^8.0.1"
+ "react": "^19.1.0",
+ "react-dom": "^19.1.0",
+ "use-debounce": "^10.0.5"
}
}
diff --git a/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/src/index.html b/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/src/index.html
deleted file mode 100644
index a3d74b719..000000000
--- a/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/src/index.html
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
My App Example
-
-
-
-
-
diff --git a/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/tsconfig.json b/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/tsconfig.json
index 3312b5f1e..a057cea1d 100644
--- a/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/tsconfig.json
+++ b/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/tsconfig.json
@@ -1,18 +1,19 @@
{
"compilerOptions": {
- "target": "es6",
- "module": "es6",
- "moduleResolution": "node",
- "declaration": false,
+ "esModuleInterop": true,
+ "isolatedModules": true,
+ "jsx": "react-jsx",
+ "lib": ["ESNext", "DOM"],
+ "module": "ESNext",
+ "moduleResolution": "bundler",
+ "noEmit": true,
"noImplicitAny": false,
- "allowSyntheticDefaultImports": true,
- "sourceMap": true,
- "jsx": "react",
- "noLib": false,
- "suppressImplicitAnyIndexErrors": true,
+ "noImplicitReturns": true,
+ "resolveJsonModule": true,
"skipLibCheck": true,
- "esModuleInterop": true
+ "sourceMap": true,
+ "target": "ESNext",
+ "useDefineForClassFields": true
},
- "include": ["src/**/*"],
- "exclude": ["node_modules"]
+ "include": ["src"]
}
diff --git a/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/vite.config.ts b/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/vite.config.ts
new file mode 100644
index 000000000..a0024d88e
--- /dev/null
+++ b/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/vite.config.ts
@@ -0,0 +1,7 @@
+import { defineConfig } from "vite";
+import checker from "vite-plugin-checker";
+import react from "@vitejs/plugin-react";
+
+export default defineConfig({
+ plugins: [checker({ typescript: true }), react()],
+});
diff --git a/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/webpack.config.js b/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/webpack.config.js
deleted file mode 100644
index 326060f82..000000000
--- a/04-frameworks/01-react/03-react-hooks/06-ajax-field-change/webpack.config.js
+++ /dev/null
@@ -1,54 +0,0 @@
-const HtmlWebpackPlugin = require("html-webpack-plugin");
-const path = require("path");
-const basePath = __dirname;
-
-module.exports = {
- context: path.join(basePath, "src"),
- resolve: {
- extensions: [".js", ".ts", ".tsx"],
- },
- entry: {
- app: ["./index.tsx", "./styles.css"],
- },
- devtool: "eval-source-map",
- stats: "errors-only",
- output: {
- filename: "[name].[chunkhash].js",
- },
- module: {
- rules: [
- {
- test: /\.tsx?$/,
- exclude: /node_modules/,
- loader: "babel-loader",
- },
- {
- test: /\.(png|jpg)$/,
- type: "asset/resource",
- },
- {
- test: /\.html$/,
- loader: "html-loader",
- },
- {
- test: /\.css$/,
- exclude: /node_modules/,
- use: [
- {
- loader: "style-loader",
- },
- {
- loader: "css-loader",
- },
- ],
- },
- ],
- },
- plugins: [
- //Generate index.html in /dist => https://github.com/ampedandwired/html-webpack-plugin
- new HtmlWebpackPlugin({
- filename: "index.html", //Name of file in ./dist/
- template: "index.html", //Name of template in ./src
- }),
- ],
-};
diff --git a/04-frameworks/01-react/03-react-hooks/07-custom-hook/.babelrc b/04-frameworks/01-react/03-react-hooks/07-custom-hook/.babelrc
deleted file mode 100644
index 469d3d55f..000000000
--- a/04-frameworks/01-react/03-react-hooks/07-custom-hook/.babelrc
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "presets": [
- "@babel/preset-env",
- "@babel/preset-typescript",
- "@babel/preset-react"
- ]
-}
diff --git a/04-frameworks/01-react/03-react-hooks/07-custom-hook/Readme.md b/04-frameworks/01-react/03-react-hooks/07-custom-hook/Readme.md
index b7cc0439c..ac3763b4f 100644
--- a/04-frameworks/01-react/03-react-hooks/07-custom-hook/Readme.md
+++ b/04-frameworks/01-react/03-react-hooks/07-custom-hook/Readme.md
@@ -1,8 +1,8 @@
# 07 Custom hooks
-## Resume
+## Summary
-This example takes as its starting point the \ _06-ajax-field-change example.
+This example takes as its starting point the \ \_06-ajax-field-change example.
Hooks are cool, but our functional component seems to get cluttered, is
there a way to extract functionality outside the functional component?
@@ -31,13 +31,13 @@ export const MyComponent = () => {
// Load full list when the component gets mounted and filter gets updated
React.useEffect(() => {
fetch(`https://jsonplaceholder.typicode.com/users?name_like=${filter}`)
- .then(response => response.json())
- .then(json => setUserCollection(json));
+ .then((response) => response.json())
+ .then((json) => setUserCollection(json));
}, [filter]);
return (