Closed latekvo closed 3 months ago
I just found that using the following code works just as well as the ManagedProps
method:
const { children, style, ...rest } = props;
The only downside being that it requires to pull out props before being used, as opposed to accessing them directly from the props object.
And so if we've got 20 unique props in one of our components, that'll require having a 20-line-long header of extracted props as opposed to pulling them on-the-go.
@j-piasecki @m-bert Would we prefer to stick with the ManagedProps
method, or remove it in favour of this new one?
ManagedProps
looks like using a sledgehammer to crack a nut. In my opinion using spread syntax is enough.
And so if we've got 20 unique props in one of our components, that'll require having a 20-line-long header of extracted props as opposed to pulling them on-the-go.
I think that it is unrealistic edge-case that we shouldn't be concerned about.
Also, I have a couple of comments on the code, but first let's see if @j-piasecki agrees with me 😅
I think that it is unrealistic edge-case that we shouldn't be concerned about.
i believe it's the exact case this PR is dealing with.
The 2 components utilising ManagedProps
are ReanimatedSwipeable
and Pressable
, both using 16
and 17
unique props respectively.
Although with all that said, I think spread operator approach is indeed simpler and more readable than ManagedProps
.
Converted to spread operator approach in 0ee242f.
i believe it's the exact case this PR is dealing with.
Oh okay, what I had in mind was only passing props to components, I forgot about the whole implementation dealing with different props. Nevertheless I believe that spread syntax is better 😅
Description
Currently large portion of the props accepted by
ReanimatedSwipeable
andPressable
components remain unused. This issue mostly refers to all theaccessibility
props.This PR adds the use of
spread
operator toReanimatedSwipeable
andPressable
to forward all the remaining props to inner components, which are not explicitly used otherwise.Fixes: #3032
Test plan
Pressable
exampleaccessibilityLabel
prop to one of thePressables
Pressable
with your keyboard (useTab
andShift-Tab
to navigate)