Skip to content

Commit

Permalink
Allow any object type for useFlags generic
Browse files Browse the repository at this point in the history
Convert to function to allow overrides

Closes #139
  • Loading branch information
ewlsh committed Sep 10, 2024
1 parent a2d6c7d commit 56f5c66
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/useFlags.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LDFlagSet } from 'launchdarkly-js-client-sdk';
import { LDFlagSet, LDFlagValue } from 'launchdarkly-js-client-sdk';
import { useContext } from 'react';
import context, { ReactSdkContext } from './context';

Expand All @@ -10,10 +10,10 @@ import context, { ReactSdkContext } from './context';
*
* @return All the feature flags configured in your LaunchDarkly project
*/
const useFlags = <T extends LDFlagSet = LDFlagSet>(): T => {
function useFlags<T extends Record<string, LDFlagValue> = LDFlagSet>(): T {
const { flags } = useContext<ReactSdkContext>(context);

return flags as T;
};
}

export default useFlags;

0 comments on commit 56f5c66

Please sign in to comment.