Permalink
Browse files

RN: Fix Type for ReactNative.NativeComponent (1/2)

Reviewed By: TheSavior

Differential Revision: D7984814

fbshipit-source-id: 0097819128b7f82267bceeb9d5e1b5057c5129ec
  • Loading branch information...
yungsters authored and facebook-github-bot committed May 13, 2018
1 parent 41a9403 commit de11ba2a5ee90929dbc67d914de59bdd2ebc29ca
Showing with 24 additions and 5 deletions.
  1. +1 −1 Libraries/Components/View/View.js
  2. +21 −2 Libraries/Renderer/shims/ReactNativeTypes.js
  3. +2 −2 Libraries/Text/Text.js
@@ -74,4 +74,4 @@ if (__DEV__) {
ViewToExport.displayName = 'View';
}
module.exports = ((ViewToExport: any): Class<NativeComponent<ViewProps, any>>);
module.exports = ((ViewToExport: any): Class<NativeComponent<ViewProps>>);
@@ -4,9 +4,12 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
*/
import * as React from 'react';
export type MeasureOnSuccessCallback = (
x: number,
y: number,
@@ -51,6 +54,22 @@ export type ReactNativeBaseComponentViewConfig = {
export type ViewConfigGetter = () => ReactNativeBaseComponentViewConfig;
/**
* Class only exists for its Flow type.
*/
class ReactNativeComponent<Props> extends React.Component<Props> {
blur(): void {}
focus(): void {}
measure(callback: MeasureOnSuccessCallback): void {}
measureInWindow(callback: MeasureInWindowOnSuccessCallback): void {}
measureLayout(
relativeToNativeNode: number,
onSuccess: MeasureLayoutOnSuccessCallback,
onFail?: () => void,
): void {}
setNativeProps(nativeProps: Object): void {}
}
/**
* This type keeps ReactNativeFiberHostComponent and NativeMethodsMixin in sync.
* It can also provide types for ReactNative applications that use NMM or refs.
@@ -86,7 +105,7 @@ type SecretInternalsFabricType = {
* Provide minimal Flow typing for the high-level RN API and call it a day.
*/
export type ReactNativeType = {
NativeComponent: any,
NativeComponent: typeof ReactNativeComponent,
findNodeHandle(componentOrHandle: any): ?number,
render(
element: React$Element<any>,
@@ -101,7 +120,7 @@ export type ReactNativeType = {
};
export type ReactFabricType = {
NativeComponent: any,
NativeComponent: typeof ReactNativeComponent,
findNodeHandle(componentOrHandle: any): ?number,
render(
element: React$Element<any>,
View
@@ -36,7 +36,7 @@ type ResponseHandlers = $ReadOnly<{|
type Props = $ReadOnly<{
...TextProps,
forwardedRef: ?React.Ref<NativeComponent<TextProps, any>>,
forwardedRef: ?React.Ref<NativeComponent<TextProps>>,
}>;
type State = {|
@@ -270,4 +270,4 @@ Text.displayName = 'Text';
// TODO: Deprecate this.
Text.propTypes = TextPropTypes;
module.exports = ((Text: any): NativeComponent<TextProps, any>);
module.exports = ((Text: any): Class<NativeComponent<TextProps>>);

0 comments on commit de11ba2

Please sign in to comment.