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 validateIp from 'validate-ip';
|
||||||
import { Doodle3DManager } from 'doodle3d-api';
|
import { Doodle3DManager } from 'doodle3d-api';
|
||||||
|
|
||||||
|
const DOODLE_3D_MANAGER = new Doodle3DManager();
|
||||||
|
DOODLE_3D_MANAGER.checkNonServerBoxes = false;
|
||||||
|
DOODLE_3D_MANAGER.setAutoUpdate(true, 5000);
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
textFieldRow: {
|
textFieldRow: {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@ -105,20 +109,15 @@ class Settings extends React.Component {
|
|||||||
this.openAddPrinterDialog();
|
this.openAddPrinterDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
const doodle3DManager = new Doodle3DManager();
|
const eventListener = ({ boxes }) => this.setState({ wifiBoxes: boxes });
|
||||||
doodle3DManager.checkNonServerBoxes = false;
|
this.setState({ wifiBoxes: DOODLE_3D_MANAGER.boxes, eventListener });
|
||||||
doodle3DManager.setAutoUpdate(true, 1000);
|
DOODLE_3D_MANAGER.addEventListener('boxeschanged', eventListener);
|
||||||
|
|
||||||
doodle3DManager.addEventListener('boxeschanged', ({ boxes: wifiBoxes }) => {
|
|
||||||
this.setState({ wifiBoxes });
|
|
||||||
});
|
|
||||||
|
|
||||||
this.setState({ doodle3DManager })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnMount() {
|
componentWillUnmount() {
|
||||||
const { doodle3DManager } = this.state;
|
console.log('remove');
|
||||||
if (doodle3DManager) doodle3DManager.setAutoUpdate(false);
|
const { eventListener } = this.state;
|
||||||
|
DOODLE_3D_MANAGER.removeEventListener('boxeschanged', eventListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
changeSettings = (fieldName, value) => {
|
changeSettings = (fieldName, value) => {
|
||||||
|
@ -115,7 +115,7 @@ class Interface extends React.Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
scene,
|
scene,
|
||||||
settings: null,
|
settings: null,
|
||||||
showFullScreen: false,
|
showFullScreen: window.innerWidth > MAX_FULLSCREEN_WIDTH,
|
||||||
isSlicing: false,
|
isSlicing: false,
|
||||||
error: null,
|
error: null,
|
||||||
mesh: null,
|
mesh: null,
|
||||||
|
Loading…
Reference in New Issue
Block a user