useCheckUsername

πŸ‘€ This hook is used to check if the selected username is taken within your organization.

The useCheckUsername hook will call and return a response from the [orgUsernameAvailable (https://developers.mojito.xyz/reference/orgusernameavailable) API.

Hooks Sample Code

...
import useCheckUsername from "mojito-hooks/useCheckUsername";

function App {
    const { usernameAvailable, checkUsername } = useCheckUsername();

    return (
        <form onSubmit={() => {...}}>
            <input name="username" onChange={(e)=>checkUsername(e.target.value)}>
            <button type="submit" disabled={usernameAvailable != false}>Submit</button>
        </form>
    );
}

Parameters

PropertyDescriptionType
usernameThe username to check.String

Result

PropertyDescriptionType
usernameAvailableReturn true or false for specified username.Boolean
checkUsernameFunction to check the username.(options: T) => Promise<U>
isLoadingDisplay request loading status, provided for convenience.Boolean
errorThe error object for the query, if an error was thrown.Error
queryResultOriginal React-Query query result.QueryResult<T>