I want to set the background image of the document body when my app component renders. The image is in the same directory as the js file however it doesn't appear.
I have the following code.
App.js
import { useEffect } from 'react';
import './App.css';
function App() {
const bg = "./clouds.png";
useEffect(() => {
document.body.style.backgroundImage = `url('${bg}')`;
}, [])
return (
<div className="App">
</div>
);
}
export default App;
clouds.png is in the src directory along with App.js