Skip to content

Commit

Permalink
basic setup
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-vahn committed Mar 27, 2024
1 parent b6ae1da commit e19198e
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 38 deletions.
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"@twa-dev/sdk": "^7.0.0",
"@vitejs/plugin-basic-ssl": "^1.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
72 changes: 42 additions & 30 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,47 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
import { useState } from 'react';
import reactLogo from './assets/react.svg';
import viteLogo from '/vite.svg';
import './App.css';

import WebApp from '@twa-dev/sdk';

function App() {
const [count, setCount] = useState(0)
const [count, setCount] = useState(0);

return (
<>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
</>
)
return (
<>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img
src={reactLogo}
className="logo react"
alt="React logo"
/>
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
</div>
{/* Here we add our button with alert callback */}
<div className="card">
<button
onClick={() =>
WebApp.showAlert(
`Hello World! Current count is ${count}`
)
}
>
Show Alert
</button>
</div>
</>
);
}

export default App
export default App;
19 changes: 11 additions & 8 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App.tsx';
import WebApp from '@twa-dev/sdk';
import './index.css';

WebApp.ready();

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
<React.StrictMode>
<App />
</React.StrictMode>
);

0 comments on commit e19198e

Please sign in to comment.