Skip to content

Commit

Permalink
Fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
poteto committed Oct 19, 2022
1 parent b69bb5d commit 96ed5e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions packages/react-reconciler/src/ReactFiberHooks.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -1947,17 +1947,21 @@ function wrapEventFunction<Args, Return, F: (...Array<Args>) => Return>(
function mountEvent<Args, Return, F: (...Array<Args>) => Return>(
callback: F,
): EventFunctionWrapper<Args, Return, F> {
const hook = mountWorkInProgressHook();
const eventFn = wrapEventFunction(callback);
hook.memoizedState = eventFn;
useEventImpl(eventFn, callback);
return eventFn;
}

function updateEvent<Args, Return, F: (...Array<Args>) => Return>(
callback: F,
): EventFunctionWrapper<Args, Return, F> {
const eventFn = wrapEventFunction(callback);
const hook = updateWorkInProgressHook();
const eventFn = hook.memoizedState;
useEventImpl(eventFn, callback);
return eventFn;
// Always return a new function
return wrapEventFunction(callback);
}

function mountInsertionEffect(
Expand Down
8 changes: 6 additions & 2 deletions packages/react-reconciler/src/ReactFiberHooks.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -1947,17 +1947,21 @@ function wrapEventFunction<Args, Return, F: (...Array<Args>) => Return>(
function mountEvent<Args, Return, F: (...Array<Args>) => Return>(
callback: F,
): EventFunctionWrapper<Args, Return, F> {
const hook = mountWorkInProgressHook();
const eventFn = wrapEventFunction(callback);
hook.memoizedState = eventFn;
useEventImpl(eventFn, callback);
return eventFn;
}

function updateEvent<Args, Return, F: (...Array<Args>) => Return>(
callback: F,
): EventFunctionWrapper<Args, Return, F> {
const eventFn = wrapEventFunction(callback);
const hook = updateWorkInProgressHook();
const eventFn = hook.memoizedState;
useEventImpl(eventFn, callback);
return eventFn;
// Always return a new function
return wrapEventFunction(callback);
}

function mountInsertionEffect(
Expand Down

0 comments on commit 96ed5e0

Please sign in to comment.