mardi 30 août 2016

How do I set an image as a background in React?

I have a <div style={styles.background}></div>

Is it possible to do something like this?

import image from 'img/image.jpg';

const styles = {
  background: {
    background: `url(${image})`
  }
};

export default styles;

I know that won't work, but is there something similar to that?

Aucun commentaire:

Enregistrer un commentaire