P
P
Pavel Kleshnin2018-11-29 22:54:14
css
Pavel Kleshnin, 2018-11-29 22:54:14

How to style React + StyledComponents pseudo-element?

There is an ArticleInfo component:

const ArticleInfo = ({key, name, url, text}) => (
    <Article key = {key}>
        <h3>{name}</h3>
        <p>{text}</p>
    </Article>
)

It is rendered like this: How can I specify for each pseudo-element in the loop?
{features.map(item => ArticleInfo(item))}
background: url(${url})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-11-30
@shake_shake1

const Article = styled.div`
  &:before {
    background-image: url(${props => props.beforeImage});
  }
  &:after {
    background-image: url(${props => props.afterImage});
  }
`;

<Article beforeImage={beforeImage} afterImage={afterImage}>
  {/* ... */}
</Article>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question