splitProps instead of destructuring?
How does
splitProps
work exactly?
In this case it's absolutely the same if I write splitProps(props, ["result"]);
or splitProps(props, []);
.
I just get props
. I know I can use:
But I'm not sure how splitProps
works.3 Replies
Is the question about the difference between the two?
i think the main use case for
splitProps
was jsx spread <div {...rest} />
where you'd know the keys in advance while preserving fine-grained updates (it's just separating prop access)
it also allows you to split multiple
const [a,b,rest] = splitProps(props, ["a"], ["b"])
Ah, so it's not a replacement for destructuring (ie flattening in my case), only splitting in different objects.