utils.tsx 600 B

1234567891011121314151617
  1. // Override the lint rule for this, we actually need the path lookup feature,
  2. // which `?.` does not magically give us.
  3. // eslint-disable-next-line no-restricted-imports
  4. import get from 'lodash/get';
  5. import type {Fuse} from 'sentry/utils/fuzzySearch';
  6. /**
  7. * A value getter for fuse that will ensure the result is a string.
  8. *
  9. * This is useful since we sometimes will pass in react nodes, which fuse will
  10. * not index.
  11. */
  12. export const strGetFn: Fuse.FuseGetFunction<any> = (value, path) => {
  13. const valueAtPath = get(value, path);
  14. return typeof valueAtPath === 'string' ? valueAtPath : '';
  15. };