mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[Flare] useListener -> useResponder (#362)
This commit is contained in:
committed by
Brian Vaughn
parent
9727f4e88f
commit
644c9c4e1c
@@ -8,7 +8,11 @@
|
||||
|
||||
import ErrorStackParser from 'error-stack-parser';
|
||||
|
||||
import type { ReactContext, ReactEventResponder } from './types';
|
||||
import type {
|
||||
ReactContext,
|
||||
ReactEventResponder,
|
||||
ReactEventResponderListener,
|
||||
} from './types';
|
||||
|
||||
type Fiber = any;
|
||||
type Hook = any;
|
||||
@@ -30,8 +34,6 @@ type HookLogEntry = {
|
||||
value: mixed,
|
||||
};
|
||||
|
||||
const emptyObject = {};
|
||||
|
||||
let hookLog: Array<HookLogEntry> = [];
|
||||
|
||||
// Primitives
|
||||
@@ -216,19 +218,20 @@ function useMemo<T>(
|
||||
return value;
|
||||
}
|
||||
|
||||
function useListener(
|
||||
function useResponder(
|
||||
responder: ReactEventResponder<any, any>,
|
||||
hookProps: ?Object
|
||||
): void {
|
||||
listenerProps: Object
|
||||
): ReactEventResponderListener<any, any> {
|
||||
// Don't put the actual event responder object in, just its displayName
|
||||
const value = {
|
||||
responder: responder.displayName || 'EventComponent',
|
||||
props: hookProps || emptyObject,
|
||||
responder: responder.displayName || 'EventResponder',
|
||||
props: listenerProps,
|
||||
};
|
||||
hookLog.push({ primitive: 'Responder', stackError: new Error(), value });
|
||||
return {
|
||||
responder,
|
||||
props: listenerProps,
|
||||
};
|
||||
hookLog.push({
|
||||
primitive: 'Listener',
|
||||
stackError: new Error(),
|
||||
value,
|
||||
});
|
||||
}
|
||||
|
||||
const Dispatcher = {
|
||||
@@ -243,7 +246,7 @@ const Dispatcher = {
|
||||
useReducer,
|
||||
useRef,
|
||||
useState,
|
||||
useListener,
|
||||
useResponder,
|
||||
};
|
||||
|
||||
// Inspect
|
||||
|
||||
@@ -371,3 +371,8 @@ export type ReactEventResponder<E, C> = {
|
||||
| null
|
||||
| ((context: C, props: Object, state: Object) => void),
|
||||
};
|
||||
|
||||
export type ReactEventResponderListener<E, C> = {|
|
||||
props: Object,
|
||||
responder: ReactEventResponder<E, C>,
|
||||
|};
|
||||
|
||||
Reference in New Issue
Block a user