is there a way to get all flags from Unleash in react?

417 Views Asked by At

I'm using @unleash/proxy-client-react package I know that we can get specific flag from unleash by "useVariant" or "useFlag". is there a way that we can get all flags at the same time from unleash or have access to unleash api response?

1

There are 1 best solutions below

1
On BEST ANSWER

You can use the useFlags hook. This will return an array with all flags:

import { useFlags } from '@unleash/proxy-client-react';

const Component = () => {
  const flags = useFlags();
  console.log(flags) // Returns all flags
  ...
}

It doesn't seem to be in the docs, but you can find the hook in the source code.