Skip to content

Commit 31ee556

Browse files
committed
refactor(react-sdk): simplify feature config retrieval
Update useFeature hook to return a reduced feature configuration with only key and payload properties, aligning with recent configuration changes in the SDK.
1 parent b6d7b9a commit 31ee556

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

packages/react-sdk/src/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ export function useFeature<TKey extends FeatureKey>(key: TKey): Feature<TKey> {
247247
});
248248
}
249249

250+
const reducedConfig = feature?.config
251+
? { key: feature.config.key, payload: feature.config.payload }
252+
: ({} as EmptyFeatureConfig);
253+
250254
return {
251255
isLoading,
252256
track,
@@ -257,7 +261,7 @@ export function useFeature<TKey extends FeatureKey>(key: TKey): Feature<TKey> {
257261
},
258262
get config() {
259263
sendCheckEvent();
260-
return feature?.config ?? ({} as EmptyFeatureConfig);
264+
return reducedConfig;
261265
},
262266
};
263267
}

packages/react-sdk/test/usage.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,7 @@ describe("useFeature", () => {
263263
isLoading: false,
264264
config: {
265265
key: "gpt3",
266-
targetingVersion: 2,
267-
value: { model: "gpt-something", temperature: 0.5 },
266+
payload: { model: "gpt-something", temperature: 0.5 },
268267
},
269268
track: expect.any(Function),
270269
requestFeedback: expect.any(Function),

0 commit comments

Comments
 (0)