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

feat: useUiFlag shorthand hook #4566

Merged
merged 2 commits into from
Sep 11, 2023
Merged

feat: useUiFlag shorthand hook #4566

merged 2 commits into from
Sep 11, 2023

Conversation

Tymek
Copy link
Member

@Tymek Tymek commented Aug 24, 2023

About the changes

Instead of this:

const { uiConfig } = useUiConfig();
const myFlag = Boolean(uiConfig?.flags?.myFlag)

we can have this:

const myFlag = useUiFlag("myFlag")

With the same type safety, less verbose and more purposeful code.

Important files

  • frontend/src/hooks/useUiFlag.ts

Discussion points

Can we in the future share flags between frontend and backend? Right now adding a new flag has to be done in 4 different places (backend flag keys list, backend flags defaults config, backend experimental server options, frontend type).

Most ergonomic option is to pull config directly from Unleash.
Issue, based on previous user feedback: #4565
Internal feature request document: docs.google.com/document/d/1Sx0q...

@vercel
Copy link

vercel bot commented Aug 24, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 8, 2023 9:42am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Sep 8, 2023 9:42am

Copy link
Member

@nunogois nunogois left a comment

Choose a reason for hiding this comment

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

I like this 👍 Maybe it would be clear enough to have it as useFlag.

@FredrikOseberg
Copy link
Contributor

FredrikOseberg commented Sep 8, 2023

I like this 👍 Maybe it would be clear enough to have it as useFlag.

useFlag is already used in our React SDK. Probably best to not conflate the terminology. Also, it fits with the current domain model, I don't need to map useUiFlag to uiFlags in the config mentally, because they are both using the same name for the same concept.

@Tymek Tymek merged commit a9ac81a into main Sep 11, 2023
13 checks passed
@Tymek Tymek deleted the feat/useUiFlag branch September 11, 2023 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants