diff --git a/developer-docs-site/docs/tutorials/first-dapp.md b/developer-docs-site/docs/tutorials/first-dapp.md index 17400679348ea..68d748a3d55ff 100644 --- a/developer-docs-site/docs/tutorials/first-dapp.md +++ b/developer-docs-site/docs/tutorials/first-dapp.md @@ -148,8 +148,18 @@ import './App.css'; function App() { // Retrieve aptos.account on initial render and store it. const [address, setAddress] = React.useState(null); + + /** + * init function + */ + const init = async() => { + // connect + const { address, publicKey } = await window.aptos.connect(); + setAddress(address); + } + React.useEffect(() => { - window.aptos.account().then((data : {address: string}) => setAddress(data.address)); + init(); }, []); return (