Skip to content

Commit cfb6c96

Browse files
Abbondanzofacebook-github-bot
authored andcommitted
Mark hasTVPreferredFocus as deprecated (#52043)
Summary: Pull Request resolved: #52043 The `hasTVPreferredFocus` prop is functionally similar to the `focusable` prop. On iOS, the props are identical. The primary difference appears on Android, where the prop attempts to request focus when set to true. Attempting to invoke imperative API calls through declarative means has been [a source of confusion](react-native-tvos/react-native-tvos#237) and we should instead recommend requesting focus through imperative means, like calling `focus()` on a specific view's ref instead. Workarounds presented rely on lifecycle methods to request focus natively. This change only marks these methods as deprecated on JS. In the following version, they will be removed from the public API. Changelog: [General][Deprecated] - Deprecate `hasTVPreferredFocus` Reviewed By: andrewdacenko Differential Revision: D76732539 fbshipit-source-id: 64912b4dacb76cd40e79148c1082d8ed8f573879
1 parent 3c17e10 commit cfb6c96

File tree

7 files changed

+12
-0
lines changed

7 files changed

+12
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export type ButtonProps = $ReadOnly<{
6363
@platform tv
6464
6565
@default false
66+
@deprecated Use `focusable` instead
6667
*/
6768
hasTVPreferredFocus?: ?boolean,
6869

packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ type AndroidProps = $ReadOnly<{
3030
}>;
3131

3232
type IOSProps = $ReadOnly<{
33+
/**
34+
* @deprecated Use `focusable` instead
35+
*/
3336
hasTVPreferredFocus?: ?boolean,
3437
}>;
3538

packages/react-native/Libraries/Components/Touchable/TouchableNativeFeedback.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type TVProps = {
2929
* *(Apple TV only)* TV preferred focus (see documentation for the View component).
3030
*
3131
* @platform ios
32+
* @deprecated Use `focusable` instead
3233
*/
3334
hasTVPreferredFocus?: ?boolean,
3435

packages/react-native/Libraries/Components/Touchable/TouchableOpacity.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface TVProps {
1616
* *(Apple TV only)* TV preferred focus (see documentation for the View component).
1717
*
1818
* @platform ios
19+
* @deprecated Use `focusable` instead
1920
*/
2021
hasTVPreferredFocus?: boolean | undefined;
2122

packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export type TVProps = $ReadOnly<{
2626
* *(Apple TV only)* TV preferred focus (see documentation for the View component).
2727
*
2828
* @platform ios
29+
* @deprecated Use `focusable` instead
2930
*/
3031
hasTVPreferredFocus?: ?boolean,
3132

packages/react-native/Libraries/Components/View/ViewPropTypes.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import {
2121
import {Touchable} from '../Touchable/Touchable';
2222
import {AccessibilityProps} from './ViewAccessibility';
2323

24+
/**
25+
* @deprecated These properties are not implemented natively.
26+
*/
2427
export interface TVViewPropsIOS {
2528
/**
2629
* *(Apple TV only)* When set to true, this view will be focusable
@@ -34,6 +37,7 @@ export interface TVViewPropsIOS {
3437
* *(Apple TV only)* May be set to true to force the Apple TV focus engine to move focus to this view.
3538
*
3639
* @platform ios
40+
* @deprecated Use `focusable` instead
3741
*/
3842
hasTVPreferredFocus?: boolean | undefined;
3943

packages/react-native/Libraries/Components/View/ViewPropTypes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ export type ViewPropsAndroid = $ReadOnly<{
280280
* Whether to force the Android TV focus engine to move focus to this view.
281281
*
282282
* @platform android
283+
* @deprecated Use `focusable` instead
283284
*/
284285
hasTVPreferredFocus?: ?boolean,
285286

0 commit comments

Comments
 (0)