mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-25 06:57:58 +01:00
fix setting state in unmounted
This commit is contained in:
parent
635e01fd01
commit
cd2b0322d8
@ -21,6 +21,10 @@ import SettingsIcon from 'material-ui-icons/Settings';
|
||||
import validateIp from 'validate-ip';
|
||||
import { Doodle3DManager } from 'doodle3d-api';
|
||||
|
||||
const DOODLE_3D_MANAGER = new Doodle3DManager();
|
||||
DOODLE_3D_MANAGER.checkNonServerBoxes = false;
|
||||
DOODLE_3D_MANAGER.setAutoUpdate(true, 5000);
|
||||
|
||||
const styles = {
|
||||
textFieldRow: {
|
||||
display: 'flex',
|
||||
@ -105,20 +109,15 @@ class Settings extends React.Component {
|
||||
this.openAddPrinterDialog();
|
||||
}
|
||||
|
||||
const doodle3DManager = new Doodle3DManager();
|
||||
doodle3DManager.checkNonServerBoxes = false;
|
||||
doodle3DManager.setAutoUpdate(true, 1000);
|
||||
|
||||
doodle3DManager.addEventListener('boxeschanged', ({ boxes: wifiBoxes }) => {
|
||||
this.setState({ wifiBoxes });
|
||||
});
|
||||
|
||||
this.setState({ doodle3DManager })
|
||||
const eventListener = ({ boxes }) => this.setState({ wifiBoxes: boxes });
|
||||
this.setState({ wifiBoxes: DOODLE_3D_MANAGER.boxes, eventListener });
|
||||
DOODLE_3D_MANAGER.addEventListener('boxeschanged', eventListener);
|
||||
}
|
||||
|
||||
componentWillUnMount() {
|
||||
const { doodle3DManager } = this.state;
|
||||
if (doodle3DManager) doodle3DManager.setAutoUpdate(false);
|
||||
componentWillUnmount() {
|
||||
console.log('remove');
|
||||
const { eventListener } = this.state;
|
||||
DOODLE_3D_MANAGER.removeEventListener('boxeschanged', eventListener);
|
||||
}
|
||||
|
||||
changeSettings = (fieldName, value) => {
|
||||
|
@ -115,7 +115,7 @@ class Interface extends React.Component {
|
||||
this.state = {
|
||||
scene,
|
||||
settings: null,
|
||||
showFullScreen: false,
|
||||
showFullScreen: window.innerWidth > MAX_FULLSCREEN_WIDTH,
|
||||
isSlicing: false,
|
||||
error: null,
|
||||
mesh: null,
|
||||
|
Loading…
Reference in New Issue
Block a user