Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/Animated/AnimatedEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export class AnimatedEvent {
this._attachedEvent && this._attachedEvent.detach();
}

__getHandler(): any | ((...args: any) => void) {
__getHandler(): (...args: any) => void {
if (this.__isNative) {
if (__DEV__) {
let validatedMapping = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,10 +576,14 @@ function unforkEventImpl(
}
}

const eventImpl = function <T>(
// NOTE: With `useNativeDriver: true` this returns an `AnimatedEvent` instance
// rather than a callable handler. That object is only ever meant to be handed
// straight back to an animated component's event prop, so the declared type
// describes the handler shape both branches are consumed as.
const eventImpl: <T>(
argMapping: ReadonlyArray<?Mapping>,
config: EventConfig<T>,
): any {
) => (...args: Array<any>) => void = function (argMapping, config): any {
const animatedEvent = new AnimatedEvent(argMapping, config);
if (animatedEvent.__isNative) {
return animatedEvent;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/ReactNativeApi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<44990574a74bcc122718d4f6142db8cd>>
* @generated SignedSource<<5335b26453a7d4d5bb9b7d54ded6218f>>
*
* This file was generated by scripts/js-api/build-types/index.js.
*/
Expand Down Expand Up @@ -232,7 +232,7 @@ declare const event: typeof $$AnimatedImplementation.event
declare const eventImpl: <T>(
argMapping: ReadonlyArray<Mapping | null | undefined>,
config: EventConfig<T>,
) => any
) => (...args: Array<any>) => void
declare const findNodeHandle: typeof $$ReactFabric.findNodeHandle
declare const flatten: typeof $$flattenStyle
declare const forkEvent: typeof $$AnimatedImplementation.forkEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ describe('Native Animated', () => {
const value = new Animated.Value(0);
value.__makeNative();
const listener = jest.fn();
const event = Animated.event([{nativeEvent: {foo: value}}], {
const event = new Animated.Event([{nativeEvent: {foo: value}}], {
useNativeDriver: true,
listener,
});
Expand Down
Loading