Skip to content

Commit 58254b9

Browse files
authored
Merge pull request #210 from thedanchez/react-examples-update
refactor: updates all react-script examples to vite
2 parents 67af021 + 3e23523 commit 58254b9

File tree

24 files changed

+297
-254
lines changed

24 files changed

+297
-254
lines changed

examples/todo-frontend-react-sdk/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
"dependencies": {
1515
"featurehub-react-sdk": "file:../../featurehub-react-sdk",
1616
"featurehub-javascript-client-sdk": "file:../../featurehub-javascript-client-sdk",
17-
"react": "^18.2.0",
18-
"react-dom": "^18.2.0"
17+
"react": "^19.2.0",
18+
"react-dom": "^19.2.0"
1919
},
2020
"devDependencies": {
21-
"@types/react": "^18.0.26",
22-
"@types/react-dom": "^18.0.9",
23-
"@vitejs/plugin-react-swc": "^3.0.0",
21+
"@types/react": "^19.2.2",
22+
"@types/react-dom": "^19.2.2",
23+
"@vitejs/plugin-react-swc": "^4.1.0",
2424
"typescript": "^5.9.3",
25-
"vite": "^4.0.0"
25+
"vite": "^7.1.9"
2626
}
2727
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<meta name="theme-color" content="#000000" />
7+
<link rel="manifest" href="/manifest.json" />
8+
<link rel="shortcut icon" href="/favicon.ico" />
9+
<title>FeatureHub React Example - Catch and Release</title>
10+
</head>
11+
<body>
12+
<noscript>You need to enable JavaScript to run this app.</noscript>
13+
<div id="root"></div>
14+
<!-- <iframe id="user-state" src="userstate/index.html" width="400px" height="300px"></iframe> -->
15+
<script type="module" src="/src/index.tsx"></script>
16+
</body>
17+
</html>

examples/todo-frontend-react-typescript-catch-and-release/package.json

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,28 @@
33
"version": "2.1.1",
44
"private": true,
55
"dependencies": {
6-
"axios": "^0.21.4",
7-
"featurehub-javascript-client-sdk": "^1.3.0",
6+
"axios": "^1.12.2",
7+
"featurehub-javascript-client-sdk": "^1.4.0",
88
"immutability-helper": "^3.1.1",
9-
"postcss": "^8.4.5",
10-
"react": "^17.0.2",
11-
"react-dom": "^17.0.2",
12-
"react-scripts": "5.0.0",
13-
"web-vitals": "^2.1.4"
9+
"react": "^19.2.0",
10+
"react-dom": "^19.2.0",
11+
"web-vitals": "^5.1.0"
1412
},
1513
"scripts": {
16-
"start": "react-scripts start",
17-
"compile": "react-scripts build",
18-
"test": "react-scripts test --env=jsdom",
19-
"eject": "react-scripts eject"
14+
"dev": "vite",
15+
"build": "tsc && vite build",
16+
"preview": "vite preview",
17+
"start": "vite",
18+
"link": "npm link featurehub-javascript-client-sdk"
2019
},
2120
"devDependencies": {
22-
"@babel/core": "^7.2.0",
23-
"@babel/eslint-parser": "^7.2.0",
2421
"@types/node": "^22.18.10",
25-
"@types/react": "^17.0.38",
26-
"@types/react-dom": "^17.0.11",
22+
"@types/react": "^19.2.2",
23+
"@types/react-dom": "^19.2.2",
24+
"@vitejs/plugin-react": "^5.0.4",
2725
"eslint": "^8.8.0",
28-
"typescript": "5.9.3"
26+
"typescript": "^5.9.3",
27+
"vite": "^7.1.9"
2928
},
30-
"browserslist": [
31-
">0.2%",
32-
"not dead",
33-
"not ie <= 11",
34-
"not op_mini all"
35-
]
29+
"type": "module"
3630
}

examples/todo-frontend-react-typescript-catch-and-release/public/index.html

Lines changed: 0 additions & 39 deletions
This file was deleted.

examples/todo-frontend-react-typescript-catch-and-release/src/App.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ class TodoData {
4646
}
4747

4848
class ConfigData {
49-
todoServerBaseUrl: string;
50-
fhEdgeUrl: string;
51-
fhApiKey: string;
49+
todoServerBaseUrl: string = "";
50+
fhEdgeUrl: string = "";
51+
fhApiKey: string = "";
5252
}
5353

5454
class App extends React.Component<{}, { todos: TodoData }> {
55-
private titleInput: HTMLInputElement;
55+
private titleInput!: HTMLInputElement;
5656

5757
constructor() {
5858
super([]);
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import * as React from "react";
2-
import * as ReactDOM from "react-dom";
2+
import { createRoot } from "react-dom/client";
33
import App from "./App";
44
import registerServiceWorker from "./registerServiceWorker";
55
import "./index.css";
66

7-
ReactDOM.render(<App />, document.getElementById("root") as HTMLElement);
7+
const container = document.getElementById("root");
8+
const root = createRoot(container!);
9+
root.render(
10+
<React.StrictMode>
11+
<App />
12+
</React.StrictMode>,
13+
);
814
registerServiceWorker();
Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
{
22
"compilerOptions": {
3-
"outDir": "build/dist",
4-
"module": "esnext",
5-
"target": "es6",
6-
"lib": ["es6", "dom"],
7-
"sourceMap": true,
8-
"allowJs": true,
9-
"jsx": "react",
10-
"moduleResolution": "node",
11-
"rootDir": "src",
12-
"forceConsistentCasingInFileNames": true,
13-
"noImplicitReturns": true,
14-
"noImplicitThis": true,
15-
"noImplicitAny": true,
16-
"strictNullChecks": true,
3+
"target": "ES2020",
4+
"useDefineForClassFields": true,
5+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
6+
"module": "ESNext",
177
"skipLibCheck": true,
18-
"suppressImplicitAnyIndexErrors": true,
19-
"noUnusedLocals": false
8+
9+
/* Bundler mode */
10+
"moduleResolution": "bundler",
11+
"allowImportingTsExtensions": true,
12+
"resolveJsonModule": true,
13+
"isolatedModules": true,
14+
"noEmit": true,
15+
"jsx": "react-jsx",
16+
17+
/* Linting */
18+
"strict": true,
19+
"noUnusedLocals": false,
20+
"noUnusedParameters": false,
21+
"noFallthroughCasesInSwitch": true,
22+
23+
/* Legacy options for compatibility */
24+
"allowJs": true,
25+
"esModuleInterop": true,
26+
"allowSyntheticDefaultImports": true,
27+
"forceConsistentCasingInFileNames": true
2028
},
21-
"include": ["src"],
22-
"exclude": [
23-
"node_modules",
24-
"build",
25-
"scripts",
26-
"acceptance-tests",
27-
"webpack",
28-
"jest",
29-
"src/setupTests.ts"
30-
]
29+
"include": ["src", "vite.config.ts"]
3130
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"skipLibCheck": true,
5+
"module": "ESNext",
6+
"moduleResolution": "bundler",
7+
"allowSyntheticDefaultImports": true,
8+
"strict": true,
9+
"noEmit": true
10+
},
11+
"include": ["vite.config.ts"]
12+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { defineConfig } from "vite";
2+
import react from "@vitejs/plugin-react";
3+
4+
export default defineConfig({
5+
plugins: [react()],
6+
server: {
7+
port: 3000,
8+
},
9+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<meta name="theme-color" content="#000000" />
7+
<link rel="manifest" href="/manifest.json" />
8+
<link rel="shortcut icon" href="/favicon.ico" />
9+
<title>FeatureHub React Example - Feature Override</title>
10+
</head>
11+
<body>
12+
<noscript>You need to enable JavaScript to run this app.</noscript>
13+
<div id="root"></div>
14+
<!-- <iframe id="user-state" src="userstate/index.html" width="400px" height="300px"></iframe> -->
15+
<script type="module" src="/src/index.tsx"></script>
16+
</body>
17+
</html>

0 commit comments

Comments
 (0)