Skip to content

Commit 59105f6

Browse files
rozelefacebook-github-bot
authored andcommitted
Adds hook for platform-specific View props
Summary: Platforms that plug in to react-native may require additional props that are specific to those platforms. For example, already in react-native there are props that are specific to Android (`accessibilityComponentType`, `needsOffscreenAlphaCompositing`, etc.), props that are specific to iOS (`accessibilityTraits`, `shouldRasterizeIOS`, etc.) and props that are specific to tvOS (`isTVSelectable`, `tvParallaxProperties`, etc.). I need to add properties to `react-native-windows`, and I'd prefer not to override the entire `ViewPropTypes` file as it is a risk that things in react-native-windows fall out of sync with react-native. Fixes #15173 <!-- Thank you for sending the PR! If you changed any code, please provide us with clear instructions on how you verified your changes work. In other words, a test plan is *required*. Bonus points for screenshots and videos! Please read the Contribution Guidelines at https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md to learn more about contributing to React Native. Happy contributing! --> Closes #15175 Differential Revision: D5481444 Pulled By: hramos fbshipit-source-id: 3da08716d03ccdf317ec447536eea3699dd7a760
1 parent 63c2ab3 commit 59105f6

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
9+
* @providesModule PlatformViewPropTypes
10+
* @flow
11+
*/
12+
13+
module.export = {};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*
9+
* @providesModule PlatformViewPropTypes
10+
* @flow
11+
*/
12+
13+
const Platform = require('Platform');
14+
15+
var TVViewPropTypes = {};
16+
if (Platform.isTVOS) {
17+
TVViewPropTypes = require('TVViewPropTypes');
18+
}
19+
20+
module.exports = TVViewPropTypes;

Libraries/Components/View/ViewPropTypes.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
'use strict';
1313

1414
const EdgeInsetsPropType = require('EdgeInsetsPropType');
15-
const Platform = require('Platform');
15+
const PlatformViewPropTypes = require('PlatformViewPropTypes');
1616
const PropTypes = require('prop-types');
1717
const StyleSheetPropType = require('StyleSheetPropType');
1818
const ViewStylePropTypes = require('ViewStylePropTypes');
@@ -22,11 +22,6 @@ const {
2222
AccessibilityTraits,
2323
} = require('ViewAccessibility');
2424

25-
var TVViewPropTypes = {};
26-
if (Platform.isTVOS) {
27-
TVViewPropTypes = require('TVViewPropTypes');
28-
}
29-
3025
import type {
3126
AccessibilityComponentType,
3227
AccessibilityTrait,
@@ -85,7 +80,7 @@ export type ViewProps = {
8580
} & TVViewProps;
8681

8782
module.exports = {
88-
...TVViewPropTypes,
83+
...PlatformViewPropTypes,
8984

9085
/**
9186
* When `true`, indicates that the view is an accessibility element. By default,

0 commit comments

Comments
 (0)