This commit is contained in:
2022-02-17 03:03:12 +08:00
parent 8a16452869
commit a1cd6cc89a
4 changed files with 111 additions and 18 deletions
+39 -17
View File
@@ -1,24 +1,46 @@
import React from 'react';
import logo from './logo.svg';
import './App.css';
import React, { useEffect, useState } from "react";
import "./App.css";
import Client from "mtproton/envs/browser";
function App() {
let [countriesList, setcountriesList] = useState([]);
useEffect(() => {
let client = new Client({
api_id: 18987971,
api_hash: "fcfd9e6ed3f9e48a360bb57cc0d59d98",
});
client.call("help.getCountriesList").then((result: any) => {
console.log("country:", result);
result.countries.map((country: any) => {
// @ts-ignore
setcountriesList((oldArray) => [
...oldArray,
country.default_name + ": " + country.country_codes[0].country_code,
]);
return true;
});
});
}, []);
// client
// .invoke({
// _: "getCountryCode",
// })
// .then((res) => {
// console.log(res);
// });
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
{countriesList.map((country: any, index) => {
return (
<div key={index}>
{country}
<br />
</div>
);
})}
</div>
);
}
+1
View File
@@ -0,0 +1 @@
declare module "mtproton/envs/browser";