I don’t know how to dismiss this issue of below :
Argument of type ‘string’ is not assignable to parameter of type ‘SetUserData’.ts(2345)
import MoralisType from "moralis";
import { useState } from "react";
import CustomContainer from "../CustomContainer";
import { FormControl, FormLabel, Text, Input, Button } from "@chakra-ui/react";
import { useMoralis } from "react-moralis";
type ProfileProps = {
user: MoralisType.User | null;
account: string | null;
};
// export default
function Profile({ user, account }: ProfileProps) {
const [input, setInput] = useState("");
const { setUserData, isUserUpdating } = useMoralis();
console.log("user ======>", user);
return (
<CustomContainer>
<Text>
<b> 😆 Username:</b>
{user && user.get("username")}
</Text>
<Text>
<b> 💰 Wallet:</b> {account}
</Text>
<form
onSubmit={(e) => {
e.preventDefault();
// input.trim != ""
if (input.trim.length > 0) {
setUserData({
username: input,
}).then(() => setUserData(""));
}
}}
>
<FormControl>
<FormLabel htmlFor="username">Set a new username</FormLabel>
<Input
id="username"
type="text"
placeholder="ex. Jesse"
value={input}
onChange={(e) => setInput(e.target.value)}
></Input>
<Button
type="submit"
mt="6"
disabled={isUserUpdating}
colorScheme="purple"
>
✅ Change Username
</Button>
</FormControl>
</form>
</CustomContainer>
);
}
export { Profile };