Skip to content

Commit c0b50de

Browse files
fix: examples to show backwards compatibility with react 18
1 parent 530da61 commit c0b50de

File tree

10 files changed

+122
-2
lines changed

10 files changed

+122
-2
lines changed

examples/demo-react-18/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!doctype html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8+
<title>DocSearch v3 - React</title>
9+
</head>
10+
11+
<body>
12+
<div id="root"></div>
13+
<script type="module" src="/src/main.tsx"></script>
14+
</body>
15+
16+
</html>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "@docsearch/react-18-example",
3+
"description": "DocSearch v3 React 18 example",
4+
"version": "3.8.3",
5+
"private": true,
6+
"license": "MIT",
7+
"type": "module",
8+
"scripts": {
9+
"dev": "vite",
10+
"build": "tsc -b && vite build",
11+
"preview": "vite preview"
12+
},
13+
"dependencies": {
14+
"@docsearch/css": "workspace:*",
15+
"@docsearch/react": "workspace:*",
16+
"react": "^18.0.0",
17+
"react-dom": "^18.0.0"
18+
},
19+
"devDependencies": {
20+
"@vitejs/plugin-react": "^4.3.4",
21+
"vite": "^6.0.7"
22+
}
23+
}
5.43 KB
Binary file not shown.

examples/demo-react-18/src/App.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
body {
2+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
3+
Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
4+
}

examples/demo-react-18/src/App.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { DocSearch } from '@docsearch/react';
2+
import type { JSX } from 'react';
3+
import './App.css';
4+
import '@docsearch/css/dist/style.css';
5+
6+
function App(): JSX.Element {
7+
return (
8+
<div>
9+
<h1>DocSearch v3 - React - 18</h1>
10+
<DocSearch indexName="vuejs" appId="ML0LEBN7FQ" apiKey="21cf9df0734770a2448a9da64a700c22" insights={true} />
11+
</div>
12+
);
13+
}
14+
15+
export default App;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { StrictMode } from 'react';
2+
import { createRoot } from 'react-dom/client';
3+
4+
import App from './App.tsx';
5+
6+
createRoot(document.getElementById('root')!).render(
7+
<StrictMode>
8+
<App />
9+
</StrictMode>,
10+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"compilerOptions": {
3+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4+
"target": "ES2020",
5+
"useDefineForClassFields": true,
6+
"lib": [
7+
"ES2020",
8+
"DOM",
9+
"DOM.Iterable"
10+
],
11+
"module": "ESNext",
12+
"skipLibCheck": true,
13+
/* Bundler mode */
14+
"moduleResolution": "Bundler",
15+
"allowImportingTsExtensions": true,
16+
"isolatedModules": true,
17+
"moduleDetection": "force",
18+
"noEmit": true,
19+
"jsx": "react-jsx",
20+
/* Linting */
21+
"strict": true,
22+
"noUnusedLocals": true,
23+
"noUnusedParameters": true,
24+
"noFallthroughCasesInSwitch": true,
25+
"noUncheckedSideEffectImports": true
26+
},
27+
"include": [
28+
"src",
29+
"vite.config.ts"
30+
],
31+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import react from '@vitejs/plugin-react';
2+
import { defineConfig } from 'vite';
3+
4+
// https://vite.dev/config/
5+
export default defineConfig({
6+
plugins: [react()],
7+
});

yarn.lock

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,7 +2089,7 @@ __metadata:
20892089
languageName: node
20902090
linkType: hard
20912091

2092-
"@docsearch/css@npm:3.8.3, @docsearch/css@workspace:packages/docsearch-css":
2092+
"@docsearch/css@npm:3.8.3, @docsearch/css@workspace:*, @docsearch/css@workspace:packages/docsearch-css":
20932093
version: 0.0.0-use.local
20942094
resolution: "@docsearch/css@workspace:packages/docsearch-css"
20952095
languageName: unknown
@@ -2173,6 +2173,19 @@ __metadata:
21732173
languageName: unknown
21742174
linkType: soft
21752175

2176+
"@docsearch/react-18-example@workspace:examples/demo-react-18":
2177+
version: 0.0.0-use.local
2178+
resolution: "@docsearch/react-18-example@workspace:examples/demo-react-18"
2179+
dependencies:
2180+
"@docsearch/css": "workspace:*"
2181+
"@docsearch/react": "workspace:*"
2182+
"@vitejs/plugin-react": "npm:^4.3.4"
2183+
react: "npm:^18.0.0"
2184+
react-dom: "npm:^18.0.0"
2185+
vite: "npm:^6.0.7"
2186+
languageName: unknown
2187+
linkType: soft
2188+
21762189
"@docsearch/react-example@workspace:examples/demo":
21772190
version: 0.0.0-use.local
21782191
resolution: "@docsearch/react-example@workspace:examples/demo"
@@ -2186,7 +2199,7 @@ __metadata:
21862199
languageName: unknown
21872200
linkType: soft
21882201

2189-
"@docsearch/react@npm:3.8.3, @docsearch/react@npm:^3.8.1, @docsearch/react@workspace:packages/docsearch-react":
2202+
"@docsearch/react@npm:3.8.3, @docsearch/react@npm:^3.8.1, @docsearch/react@workspace:*, @docsearch/react@workspace:packages/docsearch-react":
21902203
version: 0.0.0-use.local
21912204
resolution: "@docsearch/react@workspace:packages/docsearch-react"
21922205
dependencies:

0 commit comments

Comments
 (0)