Skip to content

Conversation

@TrevorBurnham
Copy link
Contributor

Note: This branch includes #4142, which should be merged first. Submitting the changes separately would cause merge conflicts.

Description

When the value object in a context provider changes, every component that consumes that context is updated. That means that something as simple as

<MyContext.Provider value={{x}}>

can create unnecessary updates: If the provider re-renders but x is the same, all context consumers will nonetheless update because a new {x} object is produced.

This PR adds memoization to all context providers to reduce unnecessary updates. This could have significant performance benefits in tables, where WidthsContext has been causing Thead to update even when no column widths changed.

How has this been tested?

Existing test coverage should be sufficient for this change.

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant