All files / hooks/intlHooks/useIntlKey useIntlKey.js

72.72% Statements 8/11
50% Branches 3/6
100% Functions 2/2
70% Lines 7/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23    27x 2565x     1123x   1123x     1123x     1123x       1123x        
import useIntlKeyStore from '../useIntlKeyStore';
 
const useIntlKey = (passedIntlKey, passedIntlNS) => {
  const getKey = useIntlKeyStore(state => state.getKey);
  let intlKey;
 
  Iif (passedIntlKey) {
    intlKey = passedIntlKey;
  } else Iif (passedIntlNS) {
    intlKey = getKey(passedIntlNS);
  } else {
    intlKey = getKey();
  }
 
  Iif (!intlKey) {
    throw new Error('Stripes kint components requires an intl key to be either configured via `addKey` from `useIntlKeyStore` or passed directly into components');
  }
 
  return intlKey;
};
 
export default useIntlKey;