Files
react-native/packages/react-native/Libraries/Image/ImageInjection.js
T
Rubén Norte 62714b002d Simplify definition of Image component decorator (#40730)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40730

This way of injecting the decorator is safer and more convenient to have the proper types inferred by Flow in the injected function.

Changelog: [internal]

Reviewed By: NickGerleman

Differential Revision: D50011840

fbshipit-source-id: 760812fc407d3e39fc7601d17488e3f2032a7065
2023-10-10 05:18:33 -07:00

27 lines
801 B
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow strict-local
*/
import type {AbstractImageAndroid, AbstractImageIOS} from './ImageTypes.flow';
type ImageComponentDecorator = (AbstractImageAndroid => AbstractImageAndroid) &
(AbstractImageIOS => AbstractImageIOS);
let injectedImageComponentDecorator: ?ImageComponentDecorator;
export function unstable_setImageComponentDecorator(
imageComponentDecorator: ?ImageComponentDecorator,
): void {
injectedImageComponentDecorator = imageComponentDecorator;
}
export function unstable_getImageComponentDecorator(): ?ImageComponentDecorator {
return injectedImageComponentDecorator;
}