Skip to content

Commit

Permalink
some twa adds
Browse files Browse the repository at this point in the history
  • Loading branch information
skuhlmann committed Nov 9, 2023
1 parent 0479529 commit 5870141
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 20 deletions.
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": "^6.9.1",
"@vitejs/plugin-basic-ssl": "^1.0.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
31 changes: 18 additions & 13 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
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 (
<>
Expand All @@ -21,15 +23,18 @@ function App() {
<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>
<div className="card">
<button
onClick={() =>
WebApp.showAlert(`Hello World! Current count is ${count}`)
}
>
Show Alert
</button>
</div>
</>
)
);
}

export default App
export default App;
18 changes: 11 additions & 7 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
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 WebApp from "@twa-dev/sdk";

ReactDOM.createRoot(document.getElementById('root')!).render(
import App from "./App.tsx";
import "./index.css";

WebApp.ready();

ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
</React.StrictMode>
);
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,18 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@twa-dev/sdk@^6.9.1":
version "6.9.1"
resolved "https://registry.yarnpkg.com/@twa-dev/sdk/-/sdk-6.9.1.tgz#bebaf53b8350e87b8f80134f87c5921d4e15a517"
integrity sha512-R+3a/IRG97NFHS1PF+rj/F2n+cwsHtW1LWGVP0pzIzMK709oMy00qJPV0wxbS16hzcvcW9hPVNwHYTPMv4rrEQ==
dependencies:
"@twa-dev/types" "^6.9.0"

"@twa-dev/types@^6.9.0":
version "6.9.0"
resolved "https://registry.yarnpkg.com/@twa-dev/types/-/types-6.9.0.tgz#5f978e63dcb8ec507ae2b035774ff568c5ebb69a"
integrity sha512-hBkIuJgVtkLAPPhKsNfgyBpgS+15spzUScy5jgpfPJPqXPaaUVDTaWHbeEUU+lUgHmryeQjWyz+UjS7987Pyaw==

"@types/babel__core@^7.20.3":
version "7.20.4"
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.4.tgz#26a87347e6c6f753b3668398e34496d6d9ac6ac0"
Expand Down

0 comments on commit 5870141

Please sign in to comment.