Skip to content

onChoice callback called multiple times #1

@lucasfeliciano

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?

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