Skip to content

Commit

Permalink
RN: Fix ReactNativeViewAttributes Type Bugs
Browse files Browse the repository at this point in the history
Summary: Fixes the runtime value of `ReactNativeStyleAttributes` to correctly map to `true` instead of strings (as returned by `keyMirror`).

Reviewed By: TheSavior

Differential Revision: D10057235

fbshipit-source-id: dc855cff3a114761098ed5176b2e6e25412481dc
  • Loading branch information
yungsters authored and facebook-github-bot committed Sep 28, 2018
1 parent e873809 commit 199c918
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions Libraries/Components/View/ReactNativeStyleAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @format strict-local
* @flow
*/

Expand All @@ -14,19 +14,19 @@ const ImageStylePropTypes = require('ImageStylePropTypes');
const TextStylePropTypes = require('TextStylePropTypes');
const ViewStylePropTypes = require('ViewStylePropTypes');

/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
* found when Flow v0.54 was deployed. To see the error delete this comment and
* run Flow. */
const keyMirror = require('fbjs/lib/keyMirror');
const processColor = require('processColor');
const processTransform = require('processTransform');
const sizesDiffer = require('sizesDiffer');

const ReactNativeStyleAttributes = {
...keyMirror(ViewStylePropTypes),
...keyMirror(TextStylePropTypes),
...keyMirror(ImageStylePropTypes),
};
const ReactNativeStyleAttributes = {};

for (const attributeName of Object.keys({
...ViewStylePropTypes,
...TextStylePropTypes,
...ImageStylePropTypes,
})) {
ReactNativeStyleAttributes[attributeName] = true;
}

ReactNativeStyleAttributes.transform = {process: processTransform};
ReactNativeStyleAttributes.shadowOffset = {diff: sizesDiffer};
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/View/ReactNativeViewAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
* @flow strict
*/

'use strict';
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Renderer/shims/ReactNativeTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export type MeasureLayoutOnSuccessCallback = (
type AttributeType =
| true
| $ReadOnly<{|
diff: ?<T>(arg1: T, arg2: T) => boolean,
process: ?(arg1: any) => any,
diff?: <T>(arg1: T, arg2: T) => boolean,
process?: (arg1: any) => any,
|}>;

export type AttributeConfiguration<
Expand Down

0 comments on commit 199c918

Please sign in to comment.