google / google/site-kit-wp

Make more considered use of `useCallback()` and `useMemo()`.

Open
#6,761 3 comments 0 reactions 0 assignees View on GitHub
P2 Type: Enhancement
Dominant language
JavaScript
Stars
1.4k
Forks
384
Avg merge
4d 14h
Merged PRs (30d)
77

Description

## Feature Description

As discussed [here](https://github.com/google/site-kit-wp/pull/6752#discussion_r1143186099), and [here](https://github.com/google/site-kit-wp/pull/6067#discussion_r1006718781) to name a couple of spots, we currently make excessive use of `useCallback()` in the codebase, even though we don't tend to use `memo` or `PureComponent` for our own components. The vast majority of these `useCallback()` calls are not adding any value, and instead are actually making a performance hit.

As mentioned in those comments, [this article](https://www.developerway.com/posts/how-to-use-memo-use-callback) is a good read for a refresher on how `useCallback()`, as well as the similar `useMemo()`, should be used.

We should review our usage of both `useCallback()` and `useMemo()` and ensure they are only used where actually necessary, and maintain this approach as we go forward.

---------------

_Do not alter or remove anything below. The following sections will be managed by moderators only._

## Acceptance criteria

*

## Implementation Brief

*

### Test Coverage

*

## QA Brief

*

## Changelog entry

*

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the two linked pull-request discussions and searching the codebase for useCallback() and useMemo() usages. Determine which uses are necessary, then remove or retain them consistently and verify that existing behavior and tests remain intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend, performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.