reactjs - Concat prop value with string in styled-component -




having trouble trying add 's' string prop passed in styled-component. also, i'm not entirely sure if can use prop.x in styled component. here's mean:

const mycomponent = (props) => {    const styledlineitem = styled.li`      animation: ${someanime};      animation-delay: ${props.x}; // <- work?  // here need add 's' end   // can't use `` becaouse of fact styled components   // in template tag already... @ least think that's why   // errors when try `${props.x}s`  // also, haven't tested using ${prop.x} in styled-component  // work?    `    return (      <styledlineitem>{props.text}</styledlineitem>    )  }    // in main component...    // ... react component stuff    render() {      return (        <ul>          {_.map(data, (item, i) => <mycomponent key={i} text={item.text})}        </ul>      )    }

let me know if can clearer on something.

add "s" after variable work fine.

`animation-delay: ${props.x}s`

code worth thousand words

var x = .3;  var = `animation-delay: ${x}s`;  var b = "animation-delay: "+x+"s";  console.log(a===b) //true





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -