trickl/react-transfer-list

View on GitHub
src/components/TransferList/useTransferList.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { useContext } from 'react';

import { TransferListContext, TransferListIds } from './TransferListContext';

export const useTransferListIds = (): TransferListIds => {
  const context = useContext(TransferListContext);

  if (context == null) {
    throw new Error(
      'useTransferList must be used within a TransferList component.'
    );
  }

  const { listIds } = context;

  return listIds;
};