Skip to content
Merged
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
4 changes: 4 additions & 0 deletions packages/interactivity/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Bug Fixes

- Hooks useMemo and useCallback should return a value. ([#60474](https://github.com/WordPress/gutenberg/pull/60474))

## 5.4.0 (2024-04-03)

## 5.3.0 (2024-03-21)
Expand Down
26 changes: 16 additions & 10 deletions packages/interactivity/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,16 @@ export function useLayoutEffect( callback, inputs ) {
* scope available so functions like `getElement()` and `getContext()` can be
* used inside the passed callback.
*
* @param {Function} callback Imperative function that can return a cleanup
* function.
* @param {any[]} inputs If present, effect will only activate if the
* values in the list change (using `===`).
* @template {Function} T The callback function type.
*
* @param {T} callback Callback function.
* @param {ReadonlyArray<unknown>} inputs If present, the callback will only be updated if the
* values in the list change (using `===`).
*
* @return {T} The callback function.
*/
export function useCallback( callback, inputs ) {
_useCallback( withScope( callback ), inputs );
return _useCallback( withScope( callback ), inputs );
}

/**
Expand All @@ -203,13 +206,16 @@ export function useCallback( callback, inputs ) {
* available so functions like `getElement()` and `getContext()` can be used
* inside the passed factory function.
*
* @param {Function} factory Imperative function that can return a cleanup
* function.
* @param {any[]} inputs If present, effect will only activate if the
* values in the list change (using `===`).
* @template {unknown} T The memoized value.
*
* @param {() => T} factory Factory function that returns that value for memoization.
* @param {ReadonlyArray<unknown>} inputs If present, the factory will only be run to recompute if
* the values in the list change (using `===`).
*
* @return {T} The memoized value.
*/
export function useMemo( factory, inputs ) {
_useMemo( withScope( factory ), inputs );
return _useMemo( withScope( factory ), inputs );
}

// For wrapperless hydration.
Expand Down