diff --git a/src/streams/StreamList.js b/src/streams/StreamList.js index ee471048630..cd8efb10dd9 100644 --- a/src/streams/StreamList.js +++ b/src/streams/StreamList.js @@ -1,5 +1,5 @@ /* @flow strict-local */ -import React, { PureComponent } from 'react'; +import React from 'react'; import { SectionList } from 'react-native'; import type { Stream, Subscription } from '../types'; @@ -38,67 +38,65 @@ type PseudoSubscription = |}>; type Props = $ReadOnly<{| - showDescriptions: boolean, - showSwitch: boolean, - streams: $ReadOnlyArray, - unreadByStream: $ReadOnly<{| [number]: number |}>, + showDescriptions?: boolean, + showSwitch?: boolean, + streams?: $ReadOnlyArray, + unreadByStream?: $ReadOnly<{| [number]: number |}>, onPress: (streamName: string) => void, onSwitch?: (streamName: string, newValue: boolean) => void, |}>; -export default class StreamList extends PureComponent { - static defaultProps = { - showDescriptions: false, - showSwitch: false, - streams: [], - unreadByStream: {}, - }; +export default function StreamList(props: Props) { + const { + streams = [], + showDescriptions = false, + showSwitch = false, + unreadByStream = {}, + onPress, + onSwitch, + } = props; - render() { - const { streams, showDescriptions, showSwitch, unreadByStream, onPress, onSwitch } = this.props; - - if (streams.length === 0) { - return ; - } + if (streams.length === 0) { + return ; + } - const sortedStreams: PseudoSubscription[] = streams - .slice() - .sort((a, b) => caseInsensitiveCompareFunc(a.name, b.name)); - const sections = [ - { - key: 'Pinned', - data: sortedStreams.filter(x => x.pin_to_top), - }, - { - key: 'Unpinned', - data: sortedStreams.filter(x => !x.pin_to_top), - }, - ]; + const sortedStreams: PseudoSubscription[] = streams + .slice() + .sort((a, b) => caseInsensitiveCompareFunc(a.name, b.name)); + const sections = [ + { + key: 'Pinned', + data: sortedStreams.filter(x => x.pin_to_top), + }, + { + key: 'Unpinned', + data: sortedStreams.filter(x => !x.pin_to_top), + }, + ]; - return ( - item.stream_id} - renderItem={({ item }: { item: PseudoSubscription, ... }) => ( - - )} - SectionSeparatorComponent={SectionSeparatorBetween} - /> - ); - } + return ( + item.stream_id} + renderItem={({ item }: { item: PseudoSubscription, ... }) => ( + + )} + SectionSeparatorComponent={SectionSeparatorBetween} + /> + ); }