Skip to content

feat(hooks): Initial useOptimizelyFeature hook #26

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

Closed
wants to merge 1 commit into from

Conversation

ajdaniel
Copy link

This is a React hook which implements the Optimizely Feature functionality.
It is very similar in functionality to the <OptimizelyFeature /> component.

usage:

import { useOptimizelyFeature } from '@optimizely/react-sdk'

function MyComponent() {
  const { isEnabled, loading } = useOptimizelyFeature('my_feature')
  if (loading) return null
  return isEnabled ? 'enabled!' : 'not-enabled'
}

Includes tests that were a copy of the Feature component tests, but with the hook instead.

@ajdaniel ajdaniel force-pushed the feat/feature_hook branch from bcca514 to 2b956d5 Compare March 5, 2020 20:02
@jamesopti
Copy link
Contributor

@ajdaniel Thanks for opening this! I actually started working on this early last week and didn't notice your pull request until Friday. Sorry about that! The good news is we arrived at a very similar result.

Would love your feedback on #28 if you're interested in reviewing! I updated mine a little bit based yours.

In the future, if you can link a PR to an issue, it will help us make sure we associate the PR correctly with the issue (in this case, #6 )

Thanks again for contributing!

@ajdaniel
Copy link
Author

Hey @jamesopti yeah I saw your PR open just after mine, I should have grabbed the issue 😞 .

I'll take a look at your PR and provide feedback. I'm happy to drop this PR in favour of yours.

@ajdaniel ajdaniel closed this Mar 10, 2020
@ajdaniel ajdaniel deleted the feat/feature_hook branch March 10, 2020 09:43
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