Skip to main content

Overview

Returns a function that removes a connection with another user by their userId, without needing the connection record ID. The server determines the correct action (withdraw, disconnect, or decline) based on the current state. The current user must be authenticated.
This hook is used internally by useConnectionManager’s removeConnectionSmart function.

Usage Example

import { useRemoveConnectionByUserId } from "@replyke/react-js";

function RemoveButton({ userId }: { userId: string }) {
  const removeConnectionByUserId = useRemoveConnectionByUserId();

  return (
    <button onClick={() => removeConnectionByUserId({ userId })}>
      Remove Connection
    </button>
  );
}

Parameters

The hook returns a function. That function accepts:
userId
string
required
The ID of the user to disconnect from. Cannot be the current user’s own ID.

Returns

id
string | undefined
The connection record ID, if applicable.
action
"withdraw" | "disconnect" | "decline" | undefined
The action performed by the server.
message
string | undefined
A confirmation message.