marvelapp / react-ab-test

A/B testing React components and debug tools. Isomorphic with a simple, universal interface. Well documented and lightweight. Tested in popular browsers and Node.js. Includes helpers for Mixpanel and Segment.com.
MIT License
240 stars 47 forks source link

Default type using useExperiment #26

Open umarjavedpresize opened 3 years ago

umarjavedpresize commented 3 years ago

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

moretti commented 3 years ago

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