Search code examples
react-nativeexpoclerk

Clerk Expo SDK throws "first_name is not a valid parameter for this request" on user.update()


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:

  • react: 18.2.0
  • react-native: 0.71.6
  • expo: ~48.0.11
  • @clerk/clerk-expo: ^0.18.16

Solution

  • 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.

    enter image description here

    From there, scroll down to the Personal Information section and make sure the checkbox is enabled.

    enter image description here