Improve render speed

This commit is contained in:
Thomas Nordquist
2019-07-08 17:17:46 +02:00
parent 901acf2bed
commit c1e2a4c625
17 changed files with 17 additions and 27 deletions

View File

@@ -10,17 +10,7 @@ import { connectionManagerActions } from '../../actions'
import { ConnectionOptions } from '../../model/ConnectionOptions' import { ConnectionOptions } from '../../model/ConnectionOptions'
import { Theme, withStyles } from '@material-ui/core/styles' import { Theme, withStyles } from '@material-ui/core/styles'
import { import { Button, Grid, IconButton, TextField, List, ListItem, ListItemText, Tooltip } from '@material-ui/core'
Button,
Grid,
IconButton,
TextField,
List,
ListItem,
ListItemText,
Tooltip,
Typography,
} from '@material-ui/core'
interface Props { interface Props {
connection: ConnectionOptions connection: ConnectionOptions

View File

@@ -18,7 +18,7 @@ interface State {
subscription: string subscription: string
} }
class Certificates extends React.Component<Props, State> { class Certificates extends React.PureComponent<Props, State> {
constructor(props: any) { constructor(props: any) {
super(props) super(props)
this.state = { subscription: '' } this.state = { subscription: '' }

View File

@@ -20,7 +20,7 @@ interface Props {
showCertificateSettings: boolean showCertificateSettings: boolean
} }
class ConnectionSetup extends React.Component<Props, {}> { class ConnectionSetup extends React.PureComponent<Props, {}> {
constructor(props: Props) { constructor(props: Props) {
super(props) super(props)
} }

View File

@@ -14,7 +14,7 @@ interface Props {
classes: any classes: any
} }
class ErrorBoundary extends React.Component<Props, State> { class ErrorBoundary extends React.PureComponent<Props, State> {
public static getDerivedStateFromError(error: Error) { public static getDerivedStateFromError(error: Error) {
return { error } return { error }
} }

View File

@@ -11,7 +11,7 @@ interface Props {
classes: any classes: any
} }
class Notification extends React.Component<Props, {}> { class Notification extends React.PureComponent<Props, {}> {
constructor(props: Props) { constructor(props: Props) {
super(props) super(props)
} }

View File

@@ -28,7 +28,7 @@ interface Props {
tree?: q.Tree<any> tree?: q.Tree<any>
} }
class PauseButton extends React.Component<Props, { changes: number }> { class PauseButton extends React.PureComponent<Props, { changes: number }> {
private timer?: any private timer?: any
constructor(props: Props) { constructor(props: Props) {
super(props) super(props)

View File

@@ -46,7 +46,7 @@ interface Props {
topicFilter?: string topicFilter?: string
} }
class TitleBar extends React.Component<Props, {}> { class TitleBar extends React.PureComponent<Props, {}> {
constructor(props: any) { constructor(props: any) {
super(props) super(props)
this.state = {} this.state = {}

View File

@@ -90,7 +90,7 @@ interface Props {
theme: 'light' | 'dark' theme: 'light' | 'dark'
} }
class Settings extends React.Component<Props, {}> { class Settings extends React.PureComponent<Props, {}> {
constructor(props: any) { constructor(props: any) {
super(props) super(props)
this.state = {} this.state = {}

View File

@@ -22,7 +22,7 @@ interface Props {
interface State {} interface State {}
class CodeDiff extends React.Component<Props, State> { class CodeDiff extends React.PureComponent<Props, State> {
private handleCtrlA = selectTextWithCtrlA({ targetSelector: 'pre ~ pre' }) private handleCtrlA = selectTextWithCtrlA({ targetSelector: 'pre ~ pre' })
constructor(props: Props) { constructor(props: Props) {

View File

@@ -24,7 +24,7 @@ const styles = (theme: Theme) => ({
}, },
}) })
class Topic extends React.Component<Props, {}> { class Topic extends React.PureComponent<Props, {}> {
public render() { public render() {
const { node, theme } = this.props const { node, theme } = this.props
if (!node) { if (!node) {

View File

@@ -41,7 +41,7 @@ interface Props {
interface State {} interface State {}
class ValuePanel extends React.Component<Props, State> { class ValuePanel extends React.PureComponent<Props, State> {
constructor(props: Props) { constructor(props: Props) {
super(props) super(props)
this.state = {} this.state = {}

View File

@@ -42,7 +42,7 @@ function nodeDotPathToHistory(startTime: number | undefined, history: q.MessageH
json = message.value ? JSON.parse(Base64Message.toUnicodeString(message.value)) : {} json = message.value ? JSON.parse(Base64Message.toUnicodeString(message.value)) : {}
} catch (ignore) {} } catch (ignore) {}
let value = dotProp.get(json, dotPath) const value = dotProp.get(json, dotPath)
return { x: message.received.getTime(), y: toPlottableValue(value) } return { x: message.received.getTime(), y: toPlottableValue(value) }
}) })

View File

@@ -45,7 +45,7 @@ interface State {
newerVersions: Array<GithubRelease> newerVersions: Array<GithubRelease>
} }
class UpdateNotifier extends React.Component<Props, State> { class UpdateNotifier extends React.PureComponent<Props, State> {
constructor(props: any) { constructor(props: any) {
super(props) super(props)
this.state = { newerVersions: [] } this.state = { newerVersions: [] }

View File

@@ -37,7 +37,7 @@ interface Props {
withBackground?: boolean withBackground?: boolean
} }
class ConnectionHealthIndicator extends React.Component<Props, {}> { class ConnectionHealthIndicator extends React.PureComponent<Props, {}> {
constructor(props: any) { constructor(props: any) {
super(props) super(props)
} }

View File

@@ -19,7 +19,7 @@ interface State {
didCopy: boolean didCopy: boolean
} }
class Copy extends React.Component<Props, State> { class Copy extends React.PureComponent<Props, State> {
constructor(props: Props) { constructor(props: Props) {
super(props) super(props)
this.state = { didCopy: false } this.state = { didCopy: false }

View File

@@ -21,7 +21,7 @@ const styles = (theme: Theme) => ({
}, },
}) })
class CustomIconButton extends React.Component<Props, {}> { class CustomIconButton extends React.PureComponent<Props, {}> {
constructor(props: Props) { constructor(props: Props) {
super(props) super(props)
} }

View File

@@ -16,7 +16,7 @@ const unitMapping = {
h: 'hours', h: 'hours',
} }
class DateFormatter extends React.Component<Props, {}> { class DateFormatter extends React.PureComponent<Props, {}> {
private intervalSince(intervalSince: Date) { private intervalSince(intervalSince: Date) {
const interval = intervalSince.getTime() - this.props.date.getTime() const interval = intervalSince.getTime() - this.props.date.getTime()
const unit = this.unitForInterval(interval) const unit = this.unitForInterval(interval)