mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: This diff updated the format of generated view configs so that they don't need to spread View props into every config, by adding a new registerGeneratedConfig function which will spread them instead This is a bit of a cleanup of the generated output but is primarily so that the view config babel plugin will not need to rely on object spreading or object.assigns Reviewed By: TheSavior, cpojer Differential Revision: D15517199 fbshipit-source-id: 08e575578177bad12d40ee3dcad9381974b6466d
71 lines
1.9 KiB
JavaScript
71 lines
1.9 KiB
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.
|
|
*
|
|
* @flow
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const ReactNativeViewConfigRegistry = require('../Renderer/shims/ReactNativeViewConfigRegistry');
|
|
const ReactNativeViewViewConfig = require('../Components/View/ReactNativeViewViewConfig');
|
|
const verifyComponentAttributeEquivalence = require('./verifyComponentAttributeEquivalence');
|
|
|
|
type GeneratedViewConfig = {
|
|
uiViewClassName: string,
|
|
bubblingEventTypes?: $ReadOnly<{
|
|
[eventName: string]: $ReadOnly<{|
|
|
phasedRegistrationNames: $ReadOnly<{|
|
|
captured: string,
|
|
bubbled: string,
|
|
|}>,
|
|
|}>,
|
|
}>,
|
|
directEventTypes?: $ReadOnly<{
|
|
[eventName: string]: $ReadOnly<{|
|
|
registrationName: string,
|
|
|}>,
|
|
}>,
|
|
validAttributes?: {
|
|
[propName: string]:
|
|
| true
|
|
| $ReadOnly<{|
|
|
diff?: <T>(arg1: any, arg2: any) => boolean,
|
|
process?: (arg1: any) => any,
|
|
|}>,
|
|
},
|
|
};
|
|
|
|
function registerGeneratedViewConfig(
|
|
componentName: string,
|
|
viewConfig: GeneratedViewConfig,
|
|
) {
|
|
const mergedViewConfig = {
|
|
uiViewClassName: viewConfig.uiViewClassName,
|
|
Commands: {},
|
|
bubblingEventTypes: {
|
|
...ReactNativeViewViewConfig.bubblingEventTypes,
|
|
...(viewConfig.bubblingEventTypes || {}),
|
|
},
|
|
directEventTypes: {
|
|
...ReactNativeViewViewConfig.directEventTypes,
|
|
...(viewConfig.directEventTypes || {}),
|
|
},
|
|
validAttributes: {
|
|
...ReactNativeViewViewConfig.validAttributes,
|
|
...(viewConfig.validAttributes || {}),
|
|
},
|
|
};
|
|
|
|
ReactNativeViewConfigRegistry.register(componentName, () => {
|
|
verifyComponentAttributeEquivalence(componentName, mergedViewConfig);
|
|
|
|
return mergedViewConfig;
|
|
});
|
|
}
|
|
|
|
module.exports = registerGeneratedViewConfig;
|