diff --git a/react-api-client/src/runs/useAllCommandsAsPreSerializedList.ts b/react-api-client/src/runs/useAllCommandsAsPreSerializedList.ts index 39ea1a1e3ab..5e1825cb764 100644 --- a/react-api-client/src/runs/useAllCommandsAsPreSerializedList.ts +++ b/react-api-client/src/runs/useAllCommandsAsPreSerializedList.ts @@ -1,3 +1,4 @@ +import mapValues from 'lodash/mapValues' import { UseQueryResult, useQuery } from 'react-query' import { getCommandsAsPreSerializedList } from '@opentrons/api-client' import { useHost } from '../api' @@ -28,18 +29,10 @@ export function useAllCommandsAsPreSerializedList( enabled: host !== null && runId != null && options.enabled !== false, } const { cursor, pageLength } = nullCheckedParams - // reduce hostKey into a new object to make nullish values play nicely with react-query key hash - const hostKey = - host != null - ? Object.entries(host).reduce((acc, current) => { - const [key, val] = current - if (val != null) { - return { ...acc, [key]: val } - } else { - return { ...acc, [key]: 'no value' } - } - }, {}) - : {} + + // map undefined values to null to agree with react query caching + // TODO (nd: 05/15/2024) create sanitizer for react query key objects + const hostKey = mapValues(host, v => (v !== undefined ? v : null)) const query = useQuery( [