import React from "react"; import PageTitle from "../../elements/PageTitle/PageTitle"; class SettingsPage extends React.Component { constructor(props, context) { super(props, context); this.state = { text: [] }; } updateStatus = () => { const updateRequest = new FormData(); fetch('/api/extractionData.php', {method: 'POST', body: updateRequest}) .then((response) => response.json() .then((result) => { if (result.contentAvailable === true) { console.log(result); this.setState({ text: [...result.message.split("\n"), ...this.state.text] }); } else { clearInterval(this.myinterval); } })) .catch(() => { console.log("no connection to backend"); }); }; componentDidMount() { if (this.myinterval) { clearInterval(this.myinterval); } this.myinterval = setInterval(this.updateStatus, 1000); } componentWillUnmount() { clearInterval(this.myinterval); } render() { return (