You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Avoid redundant state updates in Pressable if children and style are not functions (#44615)
Summary:
Goal of this PR is to optimise `Pressable` component, similarly to react-native-tvos/react-native-tvos#724 . `Pressable` `style` and `children` properties can, but doesn't have to be functions. Usually we passing objects or arrays. `pressed` state is used only when `style` or `children` are `functions`, so let's update that state only in such case, otherwise let's skip state updates to improve the performance.
That way we won't have to rerender the component when it is being pressed (assuming that `style` and `children` are not going to be functions)
## Changelog:
[GENERAL] [CHANGED] - Improve performance of `Pressable` component.
Pull Request resolved: #44615
Test Plan: Verify that `Pressable` updates its `pressed` state when `style` or `children` are functions.
Reviewed By: javache
Differential Revision: D57614309
Pulled By: fabriziocucci
fbshipit-source-id: 473e0ab3c4bf7b3ef04ba19f76105ac65371a3fb
0 commit comments