1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-12-29 03:32:04 +03:00

feat(web app): set up React

This commit is contained in:
louistiti 2023-05-14 23:43:42 +08:00
parent 96145bb2f7
commit 7a31158497
No known key found for this signature in database
GPG Key ID: 92CD6A2E497E1669
4 changed files with 45 additions and 0 deletions

View File

@ -9,6 +9,7 @@
</head>
<body class="settingup">
<main>
<div id="root"></div>
<div id="feed">
<p id="no-bubble" class="hide">
You can start to interact with Leon, don't be shy.
@ -48,5 +49,6 @@
</div>
</footer>
<script type="module" src="/js/main.js"></script>
<script type="module" src="/js/test.tsx"></script>
</body>
</html>

14
app/src/js/app.tsx Normal file
View File

@ -0,0 +1,14 @@
import { useState } from 'react'
function App() {
const [count, setCount] = useState(0)
return (
<>
<button onClick={() => setCount(count + 1)}>Click me</button>
<p>hello from React. Count: {count}</p>
</>
)
}
export default App

10
app/src/js/test.tsx Normal file
View File

@ -0,0 +1,10 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './app.tsx'
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<App />
</React.StrictMode>
)

19
app/tsconfig.json Normal file
View File

@ -0,0 +1,19 @@
{
"compilerOptions": {
"useDefineForClassFields": true,
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
}
}