rawls238 / react-experiments

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

extra <span> after <Parametrize> #23

Open saveroo opened 8 years ago

saveroo commented 8 years ago

so the case is everytime i put injectedExperiment the component are wrapped with extra , i check it with react-dev-tools The issue as in example

<Parametrize props= props=>
 <span> #extraSPAN issue
  <imageComponent />
 </span>
</Parametrize>

and this issue make the component styling a mess which is really annoying. my workaround for this are passing it from another component, so the experimentParams are passed from parent component.

rawls238 commented 7 years ago

I don't really know what can be done about this - we need to wrap the component with something. What do you suggest as an alternative? Could you put it up as a PR?

gusvargas commented 7 years ago

https://github.com/HubSpot/react-experiments/blob/master/src/parametrize.js#L72-L76 Does that span need to be there? Could it just be:

return renderedChildren;
rawls238 commented 7 years ago

afaik that'll be a problem since it wouldn't be wrapped in a parent element (similar to this issue: https://github.com/facebook/react/issues/2127), but it's easy to try it out and you're probably right. I'll try to see if it's OK later today.

rawls238 commented 7 years ago

if you simply remove the parent element you get the following error:

Invariant Violation: Parametrize.render(): A valid ReactComponent must be returned. You may have returned undefined, an array or some other invalid object.
gusvargas commented 7 years ago

Oh right, I didn't consider that renderedChildren is actually an array.