I decided to use inline JS styles in React. Everything is ok except images. Here I try to add a background image to div but I get errors.
import React, {Component} from 'react';
import ReactDOM from "react-dom";
var styles = {
color:'violet',
backgroundImage: 'url(' + require('./sun.png') + ')'
};
class App extends React.Component {
render() {
return (
<div>
<h1>How to make smth</h1>
<div style={styles}>test</div>
</div>
)
}
}
ReactDOM.render(<App/>, document.getElementById('root'));
I get errors, and I just dont know what loader do i need and how to add it to the webpack config (or package.json)