Move validateStaticViewConfigs to RNHostComponentList route

Summary:
This function is only used by the RNHostComponentList route. Let's move it into the route, so that we could keep the StaticViewConfigValidator slim.

This will also allow us to more heavily customize this function for the route.

Changelog: [Internal]

Reviewed By: p-sun

Differential Revision: D34026073

fbshipit-source-id: c3b3a93aed6007fadda2993afa52c28c028f6327
This commit is contained in:
Ramanpreet Nara
2022-02-08 17:41:06 -08:00
committed by Facebook GitHub Bot
parent bb435a2b11
commit 95f950de2a
@@ -9,10 +9,6 @@
*/
import {type ViewConfig} from '../Renderer/shims/ReactNativeTypes';
// $FlowFixMe[nonstrict-import]
import getNativeComponentAttributes from '../ReactNative/getNativeComponentAttributes';
// $FlowFixMe[nonstrict-import]
import {createViewConfig} from './ViewConfig';
import {isIgnored} from './ViewConfigIgnore';
export type Difference =
@@ -42,37 +38,6 @@ type InvalidResult = {
differences: Array<Difference>,
};
// e.g. require('MyNativeComponent') where MyNativeComponent.js exports a HostComponent
type JSModule = $FlowFixMe;
export function validateStaticViewConfigs(nativeComponent: JSModule): {
componentName: string,
nativeViewConfig?: ?ViewConfig,
staticViewConfig?: ?ViewConfig,
validationResult?: ?ValidationResult,
} {
const nativeViewConfig = getNativeComponentAttributes(
nativeComponent.default || nativeComponent,
);
const generatedPartialViewConfig = nativeComponent.__INTERNAL_VIEW_CONFIG;
const staticViewConfig: ?ViewConfig =
generatedPartialViewConfig && createViewConfig(generatedPartialViewConfig);
const componentName: string = nativeComponent.default || nativeComponent;
const validationResult: ?ValidationResult =
nativeViewConfig &&
staticViewConfig &&
validate(componentName, nativeViewConfig, staticViewConfig);
return {
componentName,
nativeViewConfig,
staticViewConfig,
validationResult,
};
}
/**
* During the migration from native view configs to static view configs, this is
* used to validate that the two are equivalent.