Replies: 1 comment 1 reply
-
Realistically it will have a performance impact. Using
For your case, to optimise renders, you should not spread the rest of the properties, but only pass through const { nestedData, isLoading } = useSomething(
{ id: 123 },
{
selectFromResult: ({ data, ...rest }) => ({
nestedData: data.some.annoyingly.deep.data,
isLoading: rest.isLoading
})
},
); If we change it to always return all data by default, then we would also need a way to opt back out of the behaviour to allow for the second dot point above. I imagine that most users would not want to be returning all data and would only want to return the pieces they are using, so I don't see this as being feasible. |
Beta Was this translation helpful? Give feedback.
-
selectFromResult
is a really convenient utility, but it can grow a bit out of hand space-wise.Assuming it wouldn't cause a significant performance impact, it'd be nice to just include the usual return properties, minus data. So the above could be rewritten like this (showing an ideal space-saving example):
Beta Was this translation helpful? Give feedback.
All reactions