Skip to content

Commit

Permalink
Merge pull request #5164 from braze-inc/FF-react
Browse files Browse the repository at this point in the history
FF-react
  • Loading branch information
josh-mccrowell-braze authored Apr 3, 2023
2 parents 67a4aed + 7e57297 commit ecdcc99
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions _docs/_developer_guide/platform_wide/feature_flags/create.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ if (featureFlag.enabled) {
}
```
{% endtab %}
{% tab React Native %}
```javascript
const featureFlag = await Braze.getFeatureFlag("expanded_user_profile");
if (featureFlag.enabled) {
console.log(`expanded_user_profile is enabled`);
} else {
console.log(`expanded_user_profile is not enabled`);
}
```
{% endtab %}
{% endtabs %}

### Accessing properties {#accessing-properties}
Expand Down Expand Up @@ -195,6 +205,16 @@ val booleanProperty = featureFlag.getBooleanProperty("expanded")
val numberProperty = featureFlag.getNumberProperty("height")
```
{% endtab %}
{% tab React Native %}
```javascript
// string properties
const stringProperty = await Braze.getFeatureFlagStringProperty("my_flag", "color");
// boolean properties
const booleanProperty = await Braze.getFeatureFlagBooleanProperty("my_flag", "expanded");
// number properties
const numberProperty = await Braze.getFeatureFlagNumberProperty("my_flag", "height");
```
{% endtab %}
{% endtabs %}

You can also get a list of all enabled feature flags:
Expand Down Expand Up @@ -232,6 +252,14 @@ featureFlags.forEach { feature ->
}
```
{% endtab %}
{% tab React Native %}
```javascript
const features = await Braze.getAllFeatureFlags();
for(const feature of features) {
console.log(`Feature: ${feature.id}`, feature.enabled);
}
```
{% endtab %}
{% endtabs %}

### Refresh feature flags {#refreshing}
Expand Down Expand Up @@ -273,6 +301,11 @@ braze.refreshFeatureFlags();
braze.refreshFeatureFlags()
```
{% endtab %}
{% tab React Native %}
```javascript
Braze.refreshFeatureFlags();
```
{% endtab %}
{% endtabs %}


Expand Down Expand Up @@ -323,6 +356,14 @@ braze.subscribeToFeatureFlagsUpdates() { event ->
}
```
{% endtab %}
{% tab React Native %}
```javascript
// register an event listener
Braze.addListener(braze.Events.FEATURE_FLAGS_UPDATED, (featureFlags) => {
console.log(`featureFlagUpdates`, JSON.stringify(featureFlags));
});
```
{% endtab %}
{% endtabs %}

## Best practices
Expand Down

0 comments on commit ecdcc99

Please sign in to comment.