react-native-macos/Libraries/DeprecatedPropTypes/DeprecatedStyleSheetPropTyp...

33 строки
1005 B
JavaScript
Исходник Обычный вид История

2015-01-30 04:10:49 +03:00
/**
* 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.
2015-01-30 04:10:49 +03:00
*
* @format
* @flow strict-local
2015-01-30 04:10:49 +03:00
*/
2015-01-30 04:10:49 +03:00
'use strict';
const deprecatedCreateStrictShapeTypeChecker = require('./deprecatedCreateStrictShapeTypeChecker');
const flattenStyle = require('../StyleSheet/flattenStyle');
2015-01-30 04:10:49 +03:00
function DeprecatedStyleSheetPropType(shape: {
[key: string]: ReactPropsCheckType,
...,
}): ReactPropsCheckType {
const shapePropType = deprecatedCreateStrictShapeTypeChecker(shape);
return function(props, propName, componentName, location?, ...rest) {
let newProps = props;
2015-01-30 04:10:49 +03:00
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);
2015-01-30 04:10:49 +03:00
};
}
module.exports = DeprecatedStyleSheetPropType;