Skip to content

Conversation

@beeme1mr
Copy link
Member

This PR

  • updated the isEqual function to compare any input
  • updated the compare to evaluate the whole EvaluationDetails object instead of just the value

Related Issues

Fixes #1286

Notes

This may trigger slightly more re-renders but I feel that that's better than return stale EvaluationDetails data which has proven to be confusing to folks attempting to debug unexpected evaluations.

Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
@beeme1mr beeme1mr requested review from a team as code owners November 21, 2025 15:31
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @beeme1mr, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where React components using feature flags might display outdated EvaluationDetails by only comparing the flag's value. The core change involves modifying the comparison logic to perform a deep equality check on the entire EvaluationDetails object. This ensures that any change in the evaluation context, such as the resolution reason or error codes, correctly triggers a re-render, providing more accurate and up-to-date flag evaluation information to consumers. While this might lead to slightly more re-renders, it prioritizes data consistency and accuracy, which is crucial for debugging and user experience.

Highlights

  • Enhanced EvaluationDetails Comparison: The useFeatureFlag hook now compares the entire EvaluationDetails object instead of just the flag's value to determine if a re-render is necessary. This prevents stale data from being displayed when non-value properties (like reason or errorCode) change.
  • Generalized isEqual Function: The internal isEqual utility function has been updated to accept unknown types, making it more flexible for comparing various data structures, and its JSDoc comments have been refined to clarify its capabilities and limitations.
  • New Test Case for Provider Ready State: A new test has been added to verify that EvaluationDetails (including the resolution reason) correctly updates and triggers a component re-render when an OpenFeature provider transitions from a NOT_READY to a READY state.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

};

describe('provider ready event updates', () => {
it('should update EvaluationDetails when provider becomes ready (including reason)', async () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This test failed before I updated the compare.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses an issue where components would not update when only the metadata of an EvaluationDetails object changed, by switching from comparing just the value to comparing the entire object. The generalization of the isEqual function to support this and the addition of a specific test case for provider readiness are both excellent improvements. However, I've identified a potential issue in the updated isEqual function where it doesn't distinguish between arrays and objects with numeric keys, which could lead to missed updates in some edge cases. I've left a suggestion to make it more robust.

@beeme1mr
Copy link
Member Author

However, I've identified a potential issue in the updated isEqual function where it doesn't distinguish between arrays and objects with numeric keys, which could lead to missed updates in some edge cases. I've left a suggestion to make it more robust.

I think these acceptable limitations.

@lukas-reining
Copy link
Member

However, I've identified a potential issue in the updated isEqual function where it doesn't distinguish between arrays and objects with numeric keys, which could lead to missed updates in some edge cases. I've left a suggestion to make it more robust.

I think these acceptable limitations.

I think so too!

Copy link
Member

@lukas-reining lukas-reining left a comment

Choose a reason for hiding this comment

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

Looks good and makes sense to me!

@toddbaert toddbaert changed the title fix(react): compare full EvaluationDetails to prevent stale data fix: compare full EvaluationDetails to prevent stale data Nov 21, 2025
* @param {FlagValue} other Second value to compare
*
* Note: Does not handle Date, RegExp, Map, Set, or circular references.
* Suitable for comparing EvaluationDetails and other JSON-serializable data.
Copy link
Member

Choose a reason for hiding this comment

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

That's a good callout.

Copy link
Member

@MattIPv4 MattIPv4 left a comment

Choose a reason for hiding this comment

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

Thank you :)

@beeme1mr beeme1mr enabled auto-merge November 21, 2025 19:41
@beeme1mr beeme1mr disabled auto-merge November 26, 2025 17:32
@beeme1mr beeme1mr merged commit 8133a4f into main Nov 26, 2025
11 checks passed
@beeme1mr beeme1mr deleted the full-evaluation-details-compare branch November 26, 2025 17:33
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.

[BUG] useFlag hooks display stale EvaluationDetails when flag value unchanged but metadata differs

5 participants