1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-23 09:32:29 +01:00

Actually fix the console memory leaking...

This commit is contained in:
Dane Everitt 2019-09-17 22:54:16 -07:00
parent 12992e3521
commit 498badc0bc
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53

View File

@ -1,5 +1,5 @@
import React, { createRef, useEffect } from 'react'; import React, { createRef, useEffect, useMemo } from 'react';
import { Terminal } from 'xterm'; import { ITerminalOptions, Terminal } from 'xterm';
import * as TerminalFit from 'xterm/lib/addons/fit/fit'; import * as TerminalFit from 'xterm/lib/addons/fit/fit';
import SpinnerOverlay from '@/components/elements/SpinnerOverlay'; import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
import { ServerContext } from '@/state/server'; import { ServerContext } from '@/state/server';
@ -25,7 +25,7 @@ const theme = {
brightWhite: '#ffffff', brightWhite: '#ffffff',
}; };
const terminal = new Terminal({ const terminalProps: ITerminalOptions = {
disableStdin: true, disableStdin: true,
cursorStyle: 'underline', cursorStyle: 'underline',
allowTransparency: true, allowTransparency: true,
@ -33,10 +33,11 @@ const terminal = new Terminal({
fontFamily: 'Menlo, Monaco, Consolas, monospace', fontFamily: 'Menlo, Monaco, Consolas, monospace',
rows: 30, rows: 30,
theme: theme, theme: theme,
}); };
export default () => { export default () => {
const ref = createRef<HTMLDivElement>(); const ref = createRef<HTMLDivElement>();
const terminal = useMemo(() => new Terminal({ ...terminalProps }), []);
const connected = ServerContext.useStoreState(state => state.socket.connected); const connected = ServerContext.useStoreState(state => state.socket.connected);
const instance = ServerContext.useStoreState(state => state.socket.instance); const instance = ServerContext.useStoreState(state => state.socket.instance);