rawls238 / react-experiments

React components for implementing UI experiments
319 stars 20 forks source link

Render default component if not enrolled in ABTest #16

Closed mattrheault closed 9 years ago

mattrheault commented 9 years ago

If I have an experiment that I want to show conditionally on some value, then I would assume that if a user is not enrolled, then they should see the children of the Default component.

EX: Here we should see the Default component render if shouldEnroll is false.

render() {
  const shouldEnroll = true || false;

  return(
    <ABTest experiment={experiment} on='foo' shouldEnroll={shouldEnroll}>
      <When value='bar'>
        {...}
      </When>
      <Default>
        {...}
      </Default>
    </ABTest>
  );
}

@rawls238 @gusvargas

rawls238 commented 9 years ago

apart from adding that test, this looks good to me.

rawls238 commented 9 years ago

Also I should really finish setting up travis-ci for this...

mattrheault commented 9 years ago

@rawls238 @gusvargas

Closing this. We talked it out and decided that shouldEnroll should be deprecated and abstracted away to the planout experiment/namespace class definition.