react-ab-test icon indicating copy to clipboard operation
react-ab-test copied to clipboard

Default type using useExperiment

Open umarjavedpresize opened this issue 4 years ago • 1 comments

  • [Expected Behavior] There should be a default type when setting Variants so that if variant is not among the ones that are listed, default component/UI is shown
  • [Current Behavior]
  • Right now, it don't show anything

My requirements are only fulfilled using useExperiment hook and I can't find anything like defaultVariantName for this hook

umarjavedpresize avatar Jun 08 '21 16:06 umarjavedpresize

This is already supported, but not well documented. The third argument of useExperiment is defaultVariantName: https://github.com/marvelapp/react-ab-test/blob/73fa6b1b40d19431db76a91dfa7d9e90ad1fc14b/src/hook.jsx#L11

Here's an example: https://codesandbox.io/s/react-ab-test-use-experiment-default-variant-g7iip

moretti avatar Jun 09 '21 08:06 moretti