Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) O3-4371: useFeatureFlag hook should not log an error if a feature flag does not exist #1273

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Bharath-K-Shetty
Copy link

@Bharath-K-Shetty Bharath-K-Shetty commented Jan 20, 2025

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. Ensure your PR title includes a conventional commit label (such as feat, fix, or chore, among others). See existing PR titles for inspiration.

For changes to apps

If applicable

  • My work includes tests or is validated by existing tests.
  • I have updated the esm-framework mock to reflect any API changes I have made.

Summary

  • Fixed issue where useFeatureFlag logged an error for non-existent flags.

  • Changed behavior to return false for missing flags instead of logging an error.

Screenshots

Related Issue

https://openmrs.atlassian.net/browse/O3-4371

Other

@Bharath-K-Shetty
Copy link
Author

@ibacher can you please review this pr.Thanks..!

Comment on lines 23 to 24
if (flags[flagName] === undefined) {
console.warn(`useFeatureFlag: Flag "${flagName}" does not exist. Returning false.`);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think a warning is really any better. We don't need to log anything. It's fine.

}
}, [flags[flagName]]);

return flags[flagName]?.enabled;
// Return false if flag does not exist or if it's off
return flags[flagName]?.enabled ?? false;
Copy link
Member

Choose a reason for hiding this comment

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

👍

@ibacher ibacher changed the title (fix)O3-4371:UseFeatureFlag hook should not log an error if a feature flag does not exist (fix) O3-4371: useFeatureFlag hook should not log an error if a feature flag does not exist Jan 30, 2025
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