1. 12
    Transforming RTK Query Data before Caching with transformResponse
    1m 13s

Transforming RTK Query Data before Caching with transformResponse

InstructorJamund Ferguson

Share this video with your friends

Send Tweet

We're currently modifying the data we get from RTK Query at the component level with useMemo. This works great when you have a single component that needs to have access to the data in a unique way. However, when you need to access that modified data in multiple components, it's better to use transformResponse.

Using transformResponse moves the data transformation into your cache, so any component subscribed to a given query will receive data in the updated format.