mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Change returning value of DirectEventHandler and BubblingEventHandler to void
Summary: returning type of Bubbling and Direct Event should be always void of Promise (if async). Other situations shouldn't be permitted. Reformated all cases when it the function wasn't void. Reviewed By: rickhanlonii Differential Revision: D16165962 fbshipit-source-id: 7c1377c3ed4bd54a431a13e5bcda4f7ec0adf4dc
This commit is contained in:
committed by
Facebook Github Bot
parent
8e4b2e7448
commit
fb7b2d3533
@@ -28,7 +28,7 @@ const DRAWER_STATES = ['Idle', 'Dragging', 'Settling'];
|
||||
|
||||
import type {ViewStyleProp} from '../../StyleSheet/StyleSheet';
|
||||
import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
|
||||
import type {SyntheticEvent} from '../../Types/CoreEventTypes';
|
||||
import type {DirectEventHandler} from '../../Types/CodegenTypes';
|
||||
import type {
|
||||
MeasureOnSuccessCallback,
|
||||
MeasureInWindowOnSuccessCallback,
|
||||
@@ -37,17 +37,9 @@ import type {
|
||||
|
||||
type DrawerStates = 'Idle' | 'Dragging' | 'Settling';
|
||||
|
||||
type DrawerStateEvent = SyntheticEvent<
|
||||
$ReadOnly<{|
|
||||
drawerState: number,
|
||||
|}>,
|
||||
>;
|
||||
|
||||
type DrawerSlideEvent = SyntheticEvent<
|
||||
$ReadOnly<{|
|
||||
offset: number,
|
||||
|}>,
|
||||
>;
|
||||
type DrawerSlideEvent = $ReadOnly<{|
|
||||
offset: number,
|
||||
|}>;
|
||||
|
||||
type Props = $ReadOnly<{|
|
||||
/**
|
||||
@@ -93,7 +85,7 @@ type Props = $ReadOnly<{|
|
||||
/**
|
||||
* Function called whenever there is an interaction with the navigation view.
|
||||
*/
|
||||
onDrawerSlide?: ?(event: DrawerSlideEvent) => mixed,
|
||||
onDrawerSlide?: ?DirectEventHandler<DrawerSlideEvent>,
|
||||
|
||||
/**
|
||||
* Function called when the drawer state has changed. The drawer can be in 3 states:
|
||||
@@ -176,7 +168,13 @@ class DrawerLayoutAndroid extends React.Component<Props, State> {
|
||||
state = {statusBarBackgroundColor: null};
|
||||
|
||||
render() {
|
||||
const {onDrawerStateChanged, renderNavigationView, ...props} = this.props;
|
||||
const {
|
||||
onDrawerStateChanged,
|
||||
renderNavigationView,
|
||||
onDrawerOpen,
|
||||
onDrawerClose,
|
||||
...props
|
||||
} = this.props;
|
||||
const drawStatusBar =
|
||||
Platform.Version >= 21 && this.props.statusBarBackgroundColor;
|
||||
const drawerViewWrapper = (
|
||||
@@ -233,7 +231,7 @@ class DrawerLayoutAndroid extends React.Component<Props, State> {
|
||||
);
|
||||
}
|
||||
|
||||
_onDrawerSlide = (event: DrawerSlideEvent) => {
|
||||
_onDrawerSlide = event => {
|
||||
if (this.props.onDrawerSlide) {
|
||||
this.props.onDrawerSlide(event);
|
||||
}
|
||||
@@ -254,7 +252,7 @@ class DrawerLayoutAndroid extends React.Component<Props, State> {
|
||||
}
|
||||
};
|
||||
|
||||
_onDrawerStateChanged = (event: DrawerStateEvent) => {
|
||||
_onDrawerStateChanged = event => {
|
||||
if (this.props.onDrawerStateChanged) {
|
||||
this.props.onDrawerStateChanged(
|
||||
DRAWER_STATES[event.nativeEvent.drawerState],
|
||||
|
||||
@@ -81,7 +81,7 @@ export type RefreshControlProps = $ReadOnly<{|
|
||||
/**
|
||||
* Called when the view starts refreshing.
|
||||
*/
|
||||
onRefresh?: ?() => mixed,
|
||||
onRefresh?: ?() => void,
|
||||
|
||||
/**
|
||||
* Whether the view should be indicating an active refresh.
|
||||
|
||||
@@ -43,7 +43,7 @@ type SegmentedControlIOSProps = $ReadOnly<{|
|
||||
/**
|
||||
* Callback that is called when the user taps a segment
|
||||
*/
|
||||
onChange?: ?(event: SyntheticEvent<OnChangeEvent>) => mixed,
|
||||
onChange?: ?(event: SyntheticEvent<OnChangeEvent>) => void,
|
||||
/**
|
||||
* Callback that is called when the user taps a segment;
|
||||
* passes the segment's value as an argument
|
||||
|
||||
@@ -29,7 +29,7 @@ const ModalEventEmitter =
|
||||
import type EmitterSubscription from '../vendor/emitter/EmitterSubscription';
|
||||
import type {ViewProps} from '../Components/View/ViewPropTypes';
|
||||
import type {SyntheticEvent} from '../Types/CoreEventTypes';
|
||||
|
||||
import type {DirectEventHandler} from '../Types/CodegenTypes';
|
||||
/**
|
||||
* The Modal component is a simple way to present content above an enclosing view.
|
||||
*
|
||||
@@ -42,11 +42,9 @@ import type {SyntheticEvent} from '../Types/CoreEventTypes';
|
||||
// destroyed before the callback is fired.
|
||||
let uniqueModalIdentifier = 0;
|
||||
|
||||
export type OrientationChangeEvent = SyntheticEvent<
|
||||
$ReadOnly<{|
|
||||
orientation: 'portrait' | 'landscape',
|
||||
|}>,
|
||||
>;
|
||||
type OrientationChangeEvent = $ReadOnly<{|
|
||||
orientation: 'portrait' | 'landscape',
|
||||
|}>;
|
||||
|
||||
export type Props = $ReadOnly<{|
|
||||
...ViewProps,
|
||||
@@ -101,7 +99,7 @@ export type Props = $ReadOnly<{|
|
||||
*
|
||||
* See https://facebook.github.io/react-native/docs/modal.html#onrequestclose
|
||||
*/
|
||||
onRequestClose?: ?(event?: SyntheticEvent<null>) => mixed,
|
||||
onRequestClose?: ?DirectEventHandler<null>,
|
||||
|
||||
/**
|
||||
* The `onShow` prop allows passing a function that will be called once the
|
||||
@@ -109,7 +107,7 @@ export type Props = $ReadOnly<{|
|
||||
*
|
||||
* See https://facebook.github.io/react-native/docs/modal.html#onshow
|
||||
*/
|
||||
onShow?: ?(event?: SyntheticEvent<null>) => mixed,
|
||||
onShow?: ?DirectEventHandler<null>,
|
||||
|
||||
/**
|
||||
* The `onDismiss` prop allows passing a function that will be called once
|
||||
@@ -142,7 +140,7 @@ export type Props = $ReadOnly<{|
|
||||
*
|
||||
* See https://facebook.github.io/react-native/docs/modal.html#onorientationchange
|
||||
*/
|
||||
onOrientationChange?: ?(event: OrientationChangeEvent) => mixed,
|
||||
onOrientationChange?: ?DirectEventHandler<OrientationChangeEvent>,
|
||||
|}>;
|
||||
|
||||
class Modal extends React.Component<Props> {
|
||||
|
||||
@@ -18,11 +18,11 @@ import type {SyntheticEvent} from './CoreEventTypes';
|
||||
export type BubblingEventHandler<
|
||||
T,
|
||||
PaperName: string | empty = empty, // eslint-disable-line no-unused-vars
|
||||
> = (event: SyntheticEvent<T>) => mixed;
|
||||
> = (event: SyntheticEvent<T>) => void | Promise<void>;
|
||||
export type DirectEventHandler<
|
||||
T,
|
||||
PaperName: string | empty = empty, // eslint-disable-line no-unused-vars
|
||||
> = (event: SyntheticEvent<T>) => mixed;
|
||||
> = (event: SyntheticEvent<T>) => void | Promise<void>;
|
||||
|
||||
// Prop types
|
||||
export type Float = number;
|
||||
|
||||
Reference in New Issue
Block a user