GeezerVison is showing github.com — Update React Native types (#20883) · react/react@8336f19
File treeExpand file treeCollapse file tree Open diff view settings packages/react-native-renderer/src
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/ReactFabric.js +12-7Lines changed: 12 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 9 | 9 |
| 10 | 10 | import type {HostComponent} from './ReactNativeTypes'; | 11 | 11 | import type {ReactNodeList} from 'shared/ReactTypes'; | 12 | | -import type {ElementRef} from 'react'; | | 12 | +import type {ElementRef, Element, ElementType} from 'react'; | 13 | 13 |
| 14 | 14 | import './ReactFabricInjection'; | 15 | 15 |
| @@ -47,8 +47,8 @@ import getComponentName from 'shared/getComponentName'; | 47 | 47 |
| 48 | 48 | const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; | 49 | 49 |
| 50 | | -function findHostInstance_DEPRECATED( | 51 | | - componentOrHandle: any, | | 50 | +function findHostInstance_DEPRECATED<TElementType: ElementType>( | | 51 | + componentOrHandle: ?(ElementRef<TElementType> | number), | 52 | 52 | ): ?ElementRef<HostComponent<mixed>> { | 53 | 53 | if (__DEV__) { | 54 | 54 | const owner = ReactCurrentOwner.current; | @@ -70,10 +70,14 @@ function findHostInstance_DEPRECATED( | 70 | 70 | if (componentOrHandle == null) { | 71 | 71 | return null; | 72 | 72 | } | | 73 | + // $FlowIssue Flow has hardcoded values for React DOM that don't work with RN | 73 | 74 | if (componentOrHandle._nativeTag) { | | 75 | + // $FlowIssue Flow has hardcoded values for React DOM that don't work with RN | 74 | 76 | return componentOrHandle; | 75 | 77 | } | | 78 | + // $FlowIssue Flow has hardcoded values for React DOM that don't work with RN | 76 | 79 | if (componentOrHandle.canonical && componentOrHandle.canonical._nativeTag) { | | 80 | + // $FlowIssue Flow has hardcoded values for React DOM that don't work with RN | 77 | 81 | return componentOrHandle.canonical; | 78 | 82 | } | 79 | 83 | let hostInstance; | @@ -194,10 +198,10 @@ function sendAccessibilityEvent(handle: any, eventType: string) { | 194 | 198 | } | 195 | 199 |
| 196 | 200 | function render( | 197 | | - element: React$Element<any>, | 198 | | - containerTag: any, | 199 | | - callback: ?Function, | 200 | | -) { | | 201 | + element: Element<ElementType>, | | 202 | + containerTag: number, | | 203 | + callback: ?() => void, | | 204 | +): ?ElementRef<ElementType> { | 201 | 205 | let root = roots.get(containerTag); | 202 | 206 |
| 203 | 207 | if (!root) { | @@ -208,6 +212,7 @@ function render( | 208 | 212 | } | 209 | 213 | updateContainer(element, root, null, callback); | 210 | 214 |
| | 215 | + // $FlowIssue Flow has hardcoded values for React DOM that don't work with RN | 211 | 216 | return getPublicRootInstance(root); | 212 | 217 | } | 213 | 218 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/ReactFabricHostConfig.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -14,7 +14,7 @@ import type { | 14 | 14 | MeasureLayoutOnSuccessCallback, | 15 | 15 | MeasureOnSuccessCallback, | 16 | 16 | NativeMethods, | 17 | | - ReactNativeBaseComponentViewConfig, | | 17 | + ViewConfig, | 18 | 18 | TouchedViewDataAtPoint, | 19 | 19 | } from './ReactNativeTypes'; | 20 | 20 |
| @@ -111,13 +111,13 @@ if (registerEventHandler) { | 111 | 111 | */ | 112 | 112 | class ReactFabricHostComponent { | 113 | 113 | _nativeTag: number; | 114 | | - viewConfig: ReactNativeBaseComponentViewConfig<>; | | 114 | + viewConfig: ViewConfig; | 115 | 115 | currentProps: Props; | 116 | 116 | _internalInstanceHandle: Object; | 117 | 117 |
| 118 | 118 | constructor( | 119 | 119 | tag: number, | 120 | | - viewConfig: ReactNativeBaseComponentViewConfig<>, | | 120 | + viewConfig: ViewConfig, | 121 | 121 | props: Props, | 122 | 122 | internalInstanceHandle: Object, | 123 | 123 | ) { | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/ReactNativeAttributePayload.js +13-13Lines changed: 13 additions & 13 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -49,7 +49,7 @@ function defaultDiffer(prevProp: mixed, nextProp: mixed): boolean { | 49 | 49 | function restoreDeletedValuesInNestedArray( | 50 | 50 | updatePayload: Object, | 51 | 51 | node: NestedNode, | 52 | | - validAttributes: AttributeConfiguration<>, | | 52 | + validAttributes: AttributeConfiguration, | 53 | 53 | ) { | 54 | 54 | if (Array.isArray(node)) { | 55 | 55 | let i = node.length; | @@ -107,7 +107,7 @@ function diffNestedArrayProperty( | 107 | 107 | updatePayload: null | Object, | 108 | 108 | prevArray: Array<NestedNode>, | 109 | 109 | nextArray: Array<NestedNode>, | 110 | | - validAttributes: AttributeConfiguration<>, | | 110 | + validAttributes: AttributeConfiguration, | 111 | 111 | ): null | Object { | 112 | 112 | const minLength = | 113 | 113 | prevArray.length < nextArray.length ? prevArray.length : nextArray.length; | @@ -145,7 +145,7 @@ function diffNestedProperty( | 145 | 145 | updatePayload: null | Object, | 146 | 146 | prevProp: NestedNode, | 147 | 147 | nextProp: NestedNode, | 148 | | - validAttributes: AttributeConfiguration<>, | | 148 | + validAttributes: AttributeConfiguration, | 149 | 149 | ): null | Object { | 150 | 150 | if (!updatePayload && prevProp === nextProp) { | 151 | 151 | // If no properties have been added, then we can bail out quickly on object | @@ -206,7 +206,7 @@ function diffNestedProperty( | 206 | 206 | function addNestedProperty( | 207 | 207 | updatePayload: null | Object, | 208 | 208 | nextProp: NestedNode, | 209 | | - validAttributes: AttributeConfiguration<>, | | 209 | + validAttributes: AttributeConfiguration, | 210 | 210 | ) { | 211 | 211 | if (!nextProp) { | 212 | 212 | return updatePayload; | @@ -236,7 +236,7 @@ function addNestedProperty( | 236 | 236 | function clearNestedProperty( | 237 | 237 | updatePayload: null | Object, | 238 | 238 | prevProp: NestedNode, | 239 | | - validAttributes: AttributeConfiguration<>, | | 239 | + validAttributes: AttributeConfiguration, | 240 | 240 | ): null | Object { | 241 | 241 | if (!prevProp) { | 242 | 242 | return updatePayload; | @@ -268,7 +268,7 @@ function diffProperties( | 268 | 268 | updatePayload: null | Object, | 269 | 269 | prevProps: Object, | 270 | 270 | nextProps: Object, | 271 | | - validAttributes: AttributeConfiguration<>, | | 271 | + validAttributes: AttributeConfiguration, | 272 | 272 | ): null | Object { | 273 | 273 | let attributeConfig; | 274 | 274 | let nextProp; | @@ -369,13 +369,13 @@ function diffProperties( | 369 | 369 | updatePayload, | 370 | 370 | prevProp, | 371 | 371 | nextProp, | 372 | | - ((attributeConfig: any): AttributeConfiguration<>), | | 372 | + ((attributeConfig: any): AttributeConfiguration), | 373 | 373 | ); | 374 | 374 | if (removedKeyCount > 0 && updatePayload) { | 375 | 375 | restoreDeletedValuesInNestedArray( | 376 | 376 | updatePayload, | 377 | 377 | nextProp, | 378 | | - ((attributeConfig: any): AttributeConfiguration<>), | | 378 | + ((attributeConfig: any): AttributeConfiguration), | 379 | 379 | ); | 380 | 380 | removedKeys = null; | 381 | 381 | } | @@ -426,7 +426,7 @@ function diffProperties( | 426 | 426 | updatePayload = clearNestedProperty( | 427 | 427 | updatePayload, | 428 | 428 | prevProp, | 429 | | - ((attributeConfig: any): AttributeConfiguration<>), | | 429 | + ((attributeConfig: any): AttributeConfiguration), | 430 | 430 | ); | 431 | 431 | } | 432 | 432 | } | @@ -439,7 +439,7 @@ function diffProperties( | 439 | 439 | function addProperties( | 440 | 440 | updatePayload: null | Object, | 441 | 441 | props: Object, | 442 | | - validAttributes: AttributeConfiguration<>, | | 442 | + validAttributes: AttributeConfiguration, | 443 | 443 | ): null | Object { | 444 | 444 | // TODO: Fast path | 445 | 445 | return diffProperties(updatePayload, emptyObject, props, validAttributes); | @@ -452,15 +452,15 @@ function addProperties( | 452 | 452 | function clearProperties( | 453 | 453 | updatePayload: null | Object, | 454 | 454 | prevProps: Object, | 455 | | - validAttributes: AttributeConfiguration<>, | | 455 | + validAttributes: AttributeConfiguration, | 456 | 456 | ): null | Object { | 457 | 457 | // TODO: Fast path | 458 | 458 | return diffProperties(updatePayload, prevProps, emptyObject, validAttributes); | 459 | 459 | } | 460 | 460 |
| 461 | 461 | export function create( | 462 | 462 | props: Object, | 463 | | - validAttributes: AttributeConfiguration<>, | | 463 | + validAttributes: AttributeConfiguration, | 464 | 464 | ): null | Object { | 465 | 465 | return addProperties( | 466 | 466 | null, // updatePayload | @@ -472,7 +472,7 @@ export function create( | 472 | 472 | export function diff( | 473 | 473 | prevProps: Object, | 474 | 474 | nextProps: Object, | 475 | | - validAttributes: AttributeConfiguration<>, | | 475 | + validAttributes: AttributeConfiguration, | 476 | 476 | ): null | Object { | 477 | 477 | return diffProperties( | 478 | 478 | null, // updatePayload | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/ReactNativeFiberHostComponent.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -14,7 +14,7 @@ import type { | 14 | 14 | MeasureLayoutOnSuccessCallback, | 15 | 15 | MeasureOnSuccessCallback, | 16 | 16 | NativeMethods, | 17 | | - ReactNativeBaseComponentViewConfig, | | 17 | + ViewConfig, | 18 | 18 | } from './ReactNativeTypes'; | 19 | 19 | import type {Instance} from './ReactNativeHostConfig'; | 20 | 20 |
| @@ -34,11 +34,11 @@ class ReactNativeFiberHostComponent { | 34 | 34 | _children: Array<Instance | number>; | 35 | 35 | _nativeTag: number; | 36 | 36 | _internalFiberInstanceHandleDEV: Object; | 37 | | - viewConfig: ReactNativeBaseComponentViewConfig<>; | | 37 | + viewConfig: ViewConfig; | 38 | 38 |
| 39 | 39 | constructor( | 40 | 40 | tag: number, | 41 | | - viewConfig: ReactNativeBaseComponentViewConfig<>, | | 41 | + viewConfig: ViewConfig, | 42 | 42 | internalInstanceHandleDEV: Object, | 43 | 43 | ) { | 44 | 44 | this._nativeTag = tag; | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/ReactNativeRenderer.js +6-4Lines changed: 6 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 9 | 9 |
| 10 | 10 | import type {HostComponent} from './ReactNativeTypes'; | 11 | 11 | import type {ReactNodeList} from 'shared/ReactTypes'; | | 12 | +import type {ElementRef, Element, ElementType} from 'react'; | 12 | 13 |
| 13 | 14 | import './ReactNativeInjection'; | 14 | 15 |
| @@ -193,10 +194,10 @@ function sendAccessibilityEvent(handle: any, eventType: string) { | 193 | 194 | } | 194 | 195 |
| 195 | 196 | function render( | 196 | | - element: React$Element<any>, | 197 | | - containerTag: any, | 198 | | - callback: ?Function, | 199 | | -) { | | 197 | + element: Element<ElementType>, | | 198 | + containerTag: number, | | 199 | + callback: ?() => void, | | 200 | +): ?ElementRef<ElementType> { | 200 | 201 | let root = roots.get(containerTag); | 201 | 202 |
| 202 | 203 | if (!root) { | @@ -207,6 +208,7 @@ function render( | 207 | 208 | } | 208 | 209 | updateContainer(element, root, null, callback); | 209 | 210 |
| | 211 | + // $FlowIssue Flow has hardcoded values for React DOM that don't work with RN | 210 | 212 | return getPublicRootInstance(root); | 211 | 213 | } | 212 | 214 |
| |
|