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: add basic react support #31

Merged
merged 1 commit into from
Oct 15, 2024
Merged

feat: add basic react support #31

merged 1 commit into from
Oct 15, 2024

Conversation

beeme1mr
Copy link
Member

This PR

  • proof-of-concept React code gen implementation

How to test

Run:

go run main.go generate react --flag_manifest_path ./sample/sample_manifest.json --output_path ./output.ts

Output

'use client';

import {
	useBooleanFlagDetails,
	useNumberFlagDetails,
	useStringFlagDetails,
} from "@openfeature/react-sdk";

/**
* Discount percentage applied to purchases.
* 
* **Details:**
* - flag key: `discountPercentage`
* - default value: `0.15`
* - type: `number`
*/
export const useDiscountPercentage = (options: Parameters<typeof useNumberFlagDetails>[2]) => {
  return useNumberFlagDetails("discountPercentage", 0.15, options);
};

/**
* Controls whether Feature A is enabled.
* 
* **Details:**
* - flag key: `enableFeatureA`
* - default value: `false`
* - type: `boolean`
*/
export const useEnableFeatureA = (options: Parameters<typeof useBooleanFlagDetails>[2]) => {
  return useBooleanFlagDetails("enableFeatureA", false, options);
};

/**
* Maximum allowed length for usernames.
* 
* **Details:**
* - flag key: `usernameMaxLength`
* - default value: `50`
* - type: `number`
*/
export const useUsernameMaxLength = (options: Parameters<typeof useNumberFlagDetails>[2]) => {
  return useNumberFlagDetails("usernameMaxLength", 50, options);
};

/**
* The message to use for greeting users.
* 
* **Details:**
* - flag key: `greetingMessage`
* - default value: `Hello there!`
* - type: `string`
*/
export const useGreetingMessage = (options: Parameters<typeof useStringFlagDetails>[2]) => {
  return useStringFlagDetails("greetingMessage", "Hello there!", options);
};

Signed-off-by: Michael Beemer <beeme1mr@users.noreply.github.com>
@anghelflorinm anghelflorinm added this pull request to the merge queue Oct 15, 2024
Merged via the queue into main with commit 757ab66 Oct 15, 2024
2 checks passed
@beeme1mr beeme1mr linked an issue Oct 17, 2024 that may be closed by this pull request
@beeme1mr beeme1mr deleted the add-react branch October 17, 2024 19:32
github-merge-queue bot pushed a commit that referenced this pull request Oct 22, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.1.2](v0.1.1...v0.1.2)
(2024-10-22)


### ✨ New Features

* add basic react support
([#31](#31))
([757ab66](757ab66))


### 🔄 Refactoring

* change folder, package structure; integrate with cobra
([#27](#27))
([850c694](850c694))

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

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@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.

Support generating React accessors
2 participants