fix(react): PostHogFeature should render fallback when flag doesn't exist#3146
Merged
gustavohstrassburger merged 4 commits intomainfrom Feb 25, 2026
Merged
Conversation
…xist When a feature flag doesn't exist and no match is specified, PostHogFeature should render the fallback instead of the children. Previously, the component would incorrectly render children because undefined === undefined was true. Added guard to check if variant exists before evaluating match conditions. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Contributor
|
Size Change: +236 B (0%) Total Size: 6.16 MB
ℹ️ View Unchanged
|
Changes the condition from `if (variant)` to `if (variant !== undefined)`
to distinguish between undefined flags (should show fallback) and explicitly
false flags (can match against match={false}).
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
marandaneto
reviewed
Feb 25, 2026
| {childNode} | ||
| </VisibilityAndClickTrackers> | ||
| ) | ||
| if (variant !== undefined) { |
Member
There was a problem hiding this comment.
https://posthog.com/docs/libraries/js/usage#enriched-flag-analytics
anyone can pass any flag to PostHogFeature
how do we know if the flag actually exists?
it could that payload and variant are undefined here
Member
There was a problem hiding this comment.
ah your last commit checks for variant
marandaneto
approved these changes
Feb 25, 2026
Member
|
dont forget to add a changeset and the label for releasing |
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The PostHogFeature component had incorrect behavior when a feature flag doesn't exist and no match is specified. Instead of rendering the fallback, it would incorrectly render the children content.
This bug occurred because the component only checked if the variant matched without first verifying if the variant exists at all.
Changes
Release info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset file