Skip to content

Conversation

@toddbaert
Copy link
Member

@toddbaert toddbaert commented Apr 2, 2024

This PR adds a new useFlag hook. This hook:

  • returns an object supporting a react "query-style" API with relevant properties: const { value: newMessage, isError, reason, errorCode, isAuthoritative, type } = useFlag('new-message', true);
  • supports ergonomic generics:
const { value: boolVal }: FlagQuery<boolean> = useFlag('bool-flag', true);
const { value: stringVal }: FlagQuery<string> = useFlag('string-flag', 'string');
const { value: objVal }: FlagQuery<{greeting: string}> = useFlag('obj-flag', { greeting: 'hi' });
  • supports all the same options and features as other hooks (suspense, etc)

This PR fixes some type bugs as well, and adds to the readme.

DEPENDS ON: #898

@toddbaert toddbaert force-pushed the feat/query-style-hook branch from c47005e to 92262fc Compare April 2, 2024 17:05
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Copy link
Member

@juanparadox juanparadox left a comment

Choose a reason for hiding this comment

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

Just some comments 😄

toddbaert and others added 3 commits April 2, 2024 13:41
Co-authored-by: Juan Bernal <juanxwtf@gmail.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
@toddbaert toddbaert force-pushed the feat/query-style-hook branch from 5933698 to ffaad95 Compare April 2, 2024 17:48
@toddbaert toddbaert requested a review from juanparadox April 2, 2024 17:48
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Copy link
Member

@moredip moredip left a comment

Choose a reason for hiding this comment

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

woop!

Co-authored-by: Pete Hodgson <github@thepete.net>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
toddbaert and others added 3 commits April 3, 2024 08:49
Co-authored-by: Pete Hodgson <github@thepete.net>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Co-authored-by: Pete Hodgson <github@thepete.net>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
@toddbaert toddbaert added this pull request to the merge queue Apr 3, 2024
Merged via the queue into main with commit 5c17b8d Apr 3, 2024
@toddbaert toddbaert deleted the feat/query-style-hook branch April 3, 2024 16:53
github-merge-queue bot pushed a commit that referenced this pull request Apr 3, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.2.4-experimental](react-sdk-v0.2.3-experimental...react-sdk-v0.2.4-experimental)
(2024-04-03)


### ✨ New Features

* query-style, generic useFlag hook
([#897](#897))
([5c17b8d](5c17b8d))


### 🔄 Refactoring

* dir restructure
([#894](#894))
([ce9f65c](ce9f65c))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Signed-off-by: OpenFeature Bot <109696520+openfeaturebot@users.noreply.github.com>
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.

5 participants