react-experiments icon indicating copy to clipboard operation
react-experiments copied to clipboard

extra <span> after <Parametrize>

Open saveroo opened this issue 8 years ago • 5 comments

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.

saveroo avatar Oct 06 '16 19:10 saveroo

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?

rawls238 avatar Jan 06 '17 14:01 rawls238

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;

gusvargas avatar Jan 06 '17 16:01 gusvargas

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 avatar Jan 06 '17 16:01 rawls238

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.

rawls238 avatar Jan 06 '17 16:01 rawls238

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

gusvargas avatar Jan 06 '17 18:01 gusvargas