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!: remove generic hook, add specific type hooks #766

Merged
merged 6 commits into from
Jan 18, 2024

Conversation

toddbaert
Copy link
Member

This PR brings the react SDK's evaluation API in-line with other SDKS. It does this by:

  • adding flag value hooks for each type (these all use common code, with only differing generic args)
  • adding flag details hooks for each type (again using common code)
  • adding optional generic constraints for each

I think this is important before a non-experimental release for 2 reasons:

  • it's consistent with our other JS components and other SDKs
  • it fixes a potential bug if uses accidentally pass the wrong default type

⚠️ This is a breaking change.

@toddbaert toddbaert requested a review from a team as a code owner January 16, 2024 14:49
Signed-off-by: Todd Baert <[email protected]>
Copy link
Member

@beeme1mr beeme1mr left a comment

Choose a reason for hiding this comment

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

value should always be present on the EvaluationDetails.

packages/react/src/use-feature-flag.ts Outdated Show resolved Hide resolved
packages/react/src/use-feature-flag.ts Outdated Show resolved Hide resolved
packages/react/src/use-feature-flag.ts Outdated Show resolved Hide resolved
packages/react/src/use-feature-flag.ts Outdated Show resolved Hide resolved
toddbaert and others added 4 commits January 16, 2024 15:54
Co-authored-by: Michael Beemer <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
Co-authored-by: Michael Beemer <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
Co-authored-by: Michael Beemer <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
Co-authored-by: Michael Beemer <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
Copy link
Contributor

@luizgribeiro luizgribeiro left a comment

Choose a reason for hiding this comment

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

The newer API made a lot o sense IMO.

LGTM!

@luizgribeiro
Copy link
Contributor

So, from what we've been exploring in the Nest SDK I think there might be a nicer way to deal with multiple providers at the same time. It's totally out of scope for this PR, but I wanted to write it down since it's the first time that I look at the React SDK.
I don't know if it is reasonable now, but could OF use one Context to store all providers resolutions and flag evaluation hooks provide the desired provider name through options?

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.

I like the change and that it makes all SDKs and components be more consistent!

@toddbaert toddbaert added this pull request to the merge queue Jan 18, 2024
Merged via the queue into main with commit d1d02fa Jan 18, 2024
8 checks passed
@toddbaert toddbaert deleted the feat/react-sdk-consistency branch January 18, 2024 16:46
github-merge-queue bot pushed a commit that referenced this pull request Jan 19, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.1.0-experimental](react-sdk-v0.0.6-experimental...react-sdk-v0.1.0-experimental)
(2024-01-18)


### ⚠ BREAKING CHANGES

* remove generic hook, add specific type hooks
([#766](#766))

### ✨ New Features

* remove generic hook, add specific type hooks
([#766](#766))
([d1d02fa](d1d02fa))


### 🧹 Chore

* fix react-sdk REAMDE example, add missing `EvaluationContext`
([#762](#762))
([1e13333](1e13333))

---
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 <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
Co-authored-by: Todd Baert <[email protected]>
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.

4 participants