import { useMemo } from 'react';
import useDelegates from '../useDelegates';
const useStateDelegates = function useStateDelegates(opts) {
  const {
    party,
    stateFips
  } = opts;
  const delegates = useDelegates(party);
  return useMemo(() => {
    if (!delegates) return undefined;
    return delegates.states.find(state => state.stateFips === stateFips);
  }, [delegates, stateFips]);
};
export default useStateDelegates;