import React, { Component } from 'react'; import Header from './Header'; import { BrowserRouter as Router, Route, Switch, } from 'react-router-dom'; import Map from './Map'; import Home from './Home'; import Vegetables from './Vegetables'; class App extends Component { constructor(props) { super(props) this.state = { background: 1 } this.changeBackground.bind = this.changeBackground(); } changeBackground = () => { setInterval(() => { let currentBackground = this.state.background; document.body.style.background = `url('/background/${currentBackground}.jpg') no-repeat fixed`; document.body.style.backgroundSize = 'cover'; document.body.style.backgroundPosition = 'center center'; if (currentBackground === 4) { currentBackground = 0 } this.setState({ background: currentBackground + 1 }) }, 10000); } render() { return (
); } } export default App;