Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
small change
Browse files Browse the repository at this point in the history
  • Loading branch information
ciaranightingale committed Sep 11, 2023
1 parent f649a7b commit 598aa4c
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions docs/onboarding/23 Smart Wallet/Guides/React.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -276,25 +276,27 @@ const connect = useConnect();
The final code should look like this:

```tsx
import { Mumbai } from "@thirdweb-dev/chains";
import { Goerli } from "@thirdweb-dev/chains";
import { useAddress, useConnect } from "@thirdweb-dev/react";
import { LocalWallet } from "@thirdweb-dev/wallets";
import { activeChain, smartWalletConfig } from "../main";
import { useState } from "react";

export const ConnectComponent = () => {
export const ConnectCompoenent = () => {
const connect = useConnect();
const address = useAddress();
const [password, setPassword] = useState("");
const [error, setError] = useState("");

const loadLocalWalletAndConnect = async () => {
if (!password) {
alert("Please enter a password");
setError("Please enter a password");
return;
}
setError("");
try {
const personalWallet = new LocalWallet({
chain: Mumbai,
chain: Goerli,
});
await personalWallet.loadOrCreate({
strategy: "encryptedJson",
Expand All @@ -304,7 +306,7 @@ export const ConnectComponent = () => {
personalWallet: personalWallet,
});
} catch (e) {
alert((e as any).message);
setError((e as any).message);
}
};

Expand All @@ -326,15 +328,18 @@ export const ConnectComponent = () => {
placeholder="Enter Password"
onChange={(e) => setPassword(e.target.value)}
/>
<br />
<br />
<button className="button" onClick={loadLocalWalletAndConnect}>
Log in
</button>
<p style={{ color: "red" }}>{error}</p>
</>
);
};
```

You can now go ahead and add this component in your App.tsx!
You can now go ahead and add this component to your `App.tsx` file!

On your homesecreen you will see an input like this:

Expand Down

0 comments on commit 598aa4c

Please sign in to comment.