Skip to content

Commit b20b4a4

Browse files
committed
Merge pull request #1351 from bbc/upstream/convert-some-components
chore: convert some class react components to functional
2 parents bd3aeaa + 8c5c933 commit b20b4a4

33 files changed

+1229
-1735
lines changed

packages/webui/src/client/lib/ConnectionStatusNotification.tsx

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { Meteor } from 'meteor/meteor'
22
import { DDP } from 'meteor/ddp'
33
import * as React from 'react'
44
import * as _ from 'underscore'
5-
6-
import { Translated } from './ReactMeteorData/react-meteor-data'
75
import { MomentFromNow } from './Moment'
8-
96
import {
107
NotificationCenter,
118
NoticeLevel,
@@ -14,13 +11,14 @@ import {
1411
NotifierHandle,
1512
} from './notifications/notifications'
1613
import { WithManagedTracker } from './reactiveData/reactiveDataHelper'
17-
import { withTranslation } from 'react-i18next'
14+
import { useTranslation } from 'react-i18next'
1815
import { NotificationCenterPopUps } from './notifications/NotificationCenterPanel'
1916
import { MeteorPubSub } from '@sofie-automation/meteor-lib/dist/api/pubsub'
2017
import { ICoreSystem, ServiceMessage, Criticality } from '@sofie-automation/meteor-lib/dist/collections/CoreSystem'
2118
import { TFunction } from 'react-i18next'
2219
import { getRandomId } from '@sofie-automation/corelib/dist/lib'
2320
import { CoreSystem } from '../collections'
21+
import { useEffect } from 'react'
2422

2523
export class ConnectionStatusNotifier extends WithManagedTracker {
2624
private _notificationList: NotificationList
@@ -233,30 +231,16 @@ function createSystemNotification(cs: ICoreSystem | undefined): Notification | u
233231
return undefined
234232
}
235233

236-
interface IProps {}
237-
interface IState {
238-
dismissed: boolean
239-
}
240-
241-
export const ConnectionStatusNotification = withTranslation()(
242-
class ConnectionStatusNotification extends React.Component<Translated<IProps>, IState> {
243-
private notifier: ConnectionStatusNotifier | undefined
244-
245-
constructor(props: Translated<IProps>) {
246-
super(props)
247-
}
234+
export function ConnectionStatusNotification(): JSX.Element {
235+
const { t } = useTranslation()
248236

249-
componentDidMount(): void {
250-
this.notifier = new ConnectionStatusNotifier(this.props.t)
251-
}
237+
useEffect(() => {
238+
const notifier = new ConnectionStatusNotifier(t)
252239

253-
componentWillUnmount(): void {
254-
if (this.notifier) this.notifier.stop()
240+
return () => {
241+
notifier.stop()
255242
}
243+
}, [t])
256244

257-
render(): JSX.Element {
258-
// this.props.connected
259-
return <NotificationCenterPopUps />
260-
}
261-
}
262-
)
245+
return <NotificationCenterPopUps />
246+
}

0 commit comments

Comments
 (0)