I try to pass a variable in a component that uses styled-components
This is how I call the component
<td><p><LimitBar width = {perc}/> {perc}%</p></td> perc is a number between 0 and 100
Then, the LimitBar is like this
const LimitBarBorder = styled.span` ...some css `; const LimitBarColored = styled.span` ...some more css width: ${props => props.width}; `; const LimitBar = (width) => ( <LimitBarBorder> <LimitBarColored width={width}></LimitBarColored> </LimitBarBorder> ); export default LimitBar; But, then, the HTML code is like this
<td> <p> <span class="sc-pHKzq izKVhe"> <span width="[object Object]" class="sc-pQFoF bkUWrD"></span> </span> 85% </p> </td> As you can see, the width parameter passed as object, while it is just a number. I am new on React and try to do it with online tutorials and official documentations.