Skip to content

Conversation

pan-kot
Copy link
Member

@pan-kot pan-kot commented Jul 14, 2025

Rel: [GNQwANHlIGi6]

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

Copy link

codecov bot commented Jul 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.41%. Comparing base (837fb68) to head (1754c94).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #145      +/-   ##
==========================================
+ Coverage   99.38%   99.41%   +0.02%     
==========================================
  Files          33       34       +1     
  Lines         810      850      +40     
  Branches      214      229      +15     
==========================================
+ Hits          805      845      +40     
  Misses          5        5              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pan-kot pan-kot marked this pull request as ready for review July 17, 2025 10:31
@pan-kot pan-kot requested a review from a team as a code owner July 17, 2025 10:31
@pan-kot pan-kot requested review from YueyingLu and connorlanigan and removed request for a team July 17, 2025 10:31
useEffect(
() => {
if (prevStore.current !== store) {
effect(selector(store.get()), selector(prevStore.current.get()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the effect runs if the store changed, even if the actual state hasn't changed. Either this should not happen (my preference) or the function's documentation should be updated to inform users of this hook about this.

Comment on lines +91 to +92
// Ignoring selector and effect as they are expected to stay constant.
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should either be documented for users of the hook, or adjusted so that they do not have to stay constant. This could likely be achieved by using the useStableCallback function. The same applies to the useSelector hook below


// We create subscription synchronously during the first render cycle to ensure the store updates that
// happen after the first render but before the first effect are not lost.
const unsubscribeRef = useRef(store.subscribe(selector, newState => setState(selector(newState))));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will create a new subscription on every render, which will likely be bad for performance over time

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.

2 participants