useRemoveConnectionByUserId
Overview
TheuseRemoveConnectionByUserId hook allows the current logged-in user to remove a connection or withdraw a connection request using a user ID instead of a connection ID. This is a convenience hook that automatically finds and removes any connection relationship with the specified user.
Usage Example
Advanced Usage with Confirmation
Usage in Connection Management
Bulk Removal by User IDs
Usage with Error Recovery
Parameters & Returns
Parameters
The hook returns a function that accepts an object with the following field:The ID of the user to remove connection with
Returns
The function returns a Promise that resolves to aRemoveConnectionByUserIdResponse object containing details about the removal operation.
Error Handling
The hook will throw errors in the following cases:- No project is specified
- No user is logged in
- No user ID is provided
- Attempting to remove connection with yourself
- No connection exists with the specified user
- Network connection issues
Advantages over useRemoveConnection
Convenience:- No need to know the specific connection ID
- Works with just a user ID (simpler API)
- Automatically handles different connection states
- Works for established connections, pending requests, and declined requests
- Single API for all connection removal scenarios
- Simpler integration in user-facing components
- More intuitive for developers building UI components
Use Cases
This hook is ideal for:- User profile connection management
- “Block” or “Remove” functionality in user lists
- Cleanup operations when users are removed
- Privacy controls and connection management
- Administrative user management interfaces
Related Hooks
useRemoveConnection- Remove connection by connection IDuseFetchConnectionStatus- Check connection status before removaluseConnectionManager- Comprehensive connection state managementuseRequestConnection- Send new connection requests after removal

