I'm trying to update user's firstName from ReactNavite app using @clerk/clerk-expo SDK:
const { user } = useUser();
const [firstName, setFirstName] = useState(user?.firstName ? user.firstName : "");
const onUpdatePress = async () => {
try {
await user?.update({ firstName: firstName });
} catch (err: any) {
setErrorMessage(err.errors[0].longMessage);
console.error(JSON.stringify(err, null, 2));
}
};
But it throws error:
ERROR {
"status": 422,
"clerkError": true,
"errors": [
{
"code": "form_param_unknown",
"message": "is unknown",
"longMessage": "first_name is not a valid parameter for this request.",
"meta": {
"paramName": "first_name"
}
}
]
}
Is it a bug or I'm doing something wrong?
Used versions:
You need to enable the Users can set their first and last name
option to set those properties. This option is disabled by default. You can find that on the Email, Phone, Username
page under the User & Authentication
section.
From there, scroll down to the Personal Information
section and make sure the checkbox is enabled.