I have a component that receives bunch of values as props, amongst them is a prop with a string value that defines the type of 'output html to return'.
something like this, which is of course wrong
const WithScrollingText = ({text,boxWidth,tag}) => {
return boxWidth > 100
? <tag>{text}</tag>
: <div className="with-scrolling-text"><div>{text}</div></div>
}
and I would call/use this component like this:
<WithScrollingText text="Something" boxWidth={250} tag="span"/>
<WithScrollingText text="Something else" boxWidth={250} tag="div"/>
and so on
How can I fix the rendering so that when I send 'span' to the component, it renders and returns an span