Skip to content

Commit 62bd1ef

Browse files
committed
Fix failing test
1 parent a4c10ec commit 62bd1ef

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

packages/react-reconciler/src/ReactFiberHooks.new.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1953,17 +1953,21 @@ function wrapEventFunction<Args, Return, F: (...Array<Args>) => Return>(
19531953
function mountEvent<Args, Return, F: (...Array<Args>) => Return>(
19541954
callback: F,
19551955
): EventFunctionWrapper<Args, Return, F> {
1956+
const hook = mountWorkInProgressHook();
19561957
const eventFn = wrapEventFunction(callback);
1958+
hook.memoizedState = eventFn;
19571959
useEventImpl(eventFn, callback);
19581960
return eventFn;
19591961
}
19601962

19611963
function updateEvent<Args, Return, F: (...Array<Args>) => Return>(
19621964
callback: F,
19631965
): EventFunctionWrapper<Args, Return, F> {
1964-
const eventFn = wrapEventFunction(callback);
1966+
const hook = updateWorkInProgressHook();
1967+
const eventFn = hook.memoizedState;
19651968
useEventImpl(eventFn, callback);
1966-
return eventFn;
1969+
// Always return a new function
1970+
return wrapEventFunction(callback);
19671971
}
19681972

19691973
function mountInsertionEffect(

packages/react-reconciler/src/ReactFiberHooks.old.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1953,17 +1953,21 @@ function wrapEventFunction<Args, Return, F: (...Array<Args>) => Return>(
19531953
function mountEvent<Args, Return, F: (...Array<Args>) => Return>(
19541954
callback: F,
19551955
): EventFunctionWrapper<Args, Return, F> {
1956+
const hook = mountWorkInProgressHook();
19561957
const eventFn = wrapEventFunction(callback);
1958+
hook.memoizedState = eventFn;
19571959
useEventImpl(eventFn, callback);
19581960
return eventFn;
19591961
}
19601962

19611963
function updateEvent<Args, Return, F: (...Array<Args>) => Return>(
19621964
callback: F,
19631965
): EventFunctionWrapper<Args, Return, F> {
1964-
const eventFn = wrapEventFunction(callback);
1966+
const hook = updateWorkInProgressHook();
1967+
const eventFn = hook.memoizedState;
19651968
useEventImpl(eventFn, callback);
1966-
return eventFn;
1969+
// Always return a new function
1970+
return wrapEventFunction(callback);
19671971
}
19681972

19691973
function mountInsertionEffect(

0 commit comments

Comments
 (0)