Skip to content

Commit 28c375f

Browse files
SamChou19815facebook-github-bot
authored andcommitted
Make use of ref-as-prop support in Switch (facebook#51353)
Summary: Pull Request resolved: facebook#51353 Make use of the React 19 feature so that we can remove the remaining `forwardRef` in react native. Changelog: [Internal] Reviewed By: yungsters Differential Revision: D74809899 fbshipit-source-id: aaa4ef65ea4d4a20c9d9315ae95957e67484c2d8
1 parent 83401b5 commit 28c375f

File tree

1 file changed

+8
-2
lines changed
  • packages/react-native/Libraries/Components/Switch

1 file changed

+8
-2
lines changed

packages/react-native/Libraries/Components/Switch/Switch.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,13 @@ type SwitchRef = React.ElementRef<
165165
const Switch: component(
166166
ref?: React.RefSetter<SwitchRef>,
167167
...props: SwitchProps
168-
) = React.forwardRef(function Switch(props, forwardedRef): React.Node {
168+
) = function Switch({
169+
ref: forwardedRef,
170+
...props
171+
}: {
172+
ref?: React.RefSetter<SwitchRef>,
173+
...SwitchProps,
174+
}): React.Node {
169175
const {
170176
disabled,
171177
ios_backgroundColor,
@@ -285,6 +291,6 @@ const Switch: component(
285291
/>
286292
);
287293
}
288-
});
294+
};
289295

290296
export default Switch;

0 commit comments

Comments
 (0)