react-native/Libraries/DeprecatedPropTypes/DeprecatedStyleSheetPropType.js
Dani d8b40cc541 Move and rename StyleSheetPropType to DeprecatedStyleSheetPropType (#21380)
Summary:
This PR moves and renames all references of StyleSheetPropType  to DeprecatedStyleSheetPropType
Related to #21342
Pull Request resolved: https://github.com/facebook/react-native/pull/21380

Differential Revision: D10098216

Pulled By: TheSavior

fbshipit-source-id: da8d927f87bd37cdabc315e0aa17b6ae208f7124
2018-09-27 23:04:20 -07:00

32 lines
952 B
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow strict-local
*/
'use strict';
const createStrictShapeTypeChecker = require('createStrictShapeTypeChecker');
const flattenStyle = require('flattenStyle');
function DeprecatedStyleSheetPropType(shape: {
[key: string]: ReactPropsCheckType,
}): ReactPropsCheckType {
const shapePropType = createStrictShapeTypeChecker(shape);
return function(props, propName, componentName, location?, ...rest) {
let newProps = props;
if (props[propName]) {
// Just make a dummy prop object with only the flattened style
newProps = {};
newProps[propName] = flattenStyle(props[propName]);
}
return shapePropType(newProps, propName, componentName, location, ...rest);
};
}
module.exports = DeprecatedStyleSheetPropType;