Skip to content

Commit

Permalink
Move validateStaticViewConfigs to RNHostComponentList route
Browse files Browse the repository at this point in the history
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
  • Loading branch information
RSNara authored and facebook-github-bot committed Feb 9, 2022
1 parent bb435a2 commit 95f950d
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions Libraries/NativeComponent/StaticViewConfigValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 95f950d

Please sign in to comment.