Skip to content

onChoice callback called multiple times #1

Description

@lucasfeliciano

I'm using onChoice callback to trigger some tracking, however, it is being called two times

          <Experiment
            name="Wanted listing button label"
            onChoice={(experimentName, variantName) => {
              console.log('test', Math.random())
              track(EXPERIMENT_VIEWED, {
                variant: variantName,
                experiment: experimentName,
              })
              setExperiment(experimentName)
              setVariant(variantName)
            }}
          >
            <Variant name="A (current)">{t('event:cta.wanted')}</Variant>
            <Variant name="B (new)">{t('event:cta.wanted_variant')}</Variant>
          </Experiment>

So on render this is the output

image

I tried to make my component a pure component or even using memo on Experiment component with no success.

Any ideas?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions