1
1
/* @flow strict-local */
2
2
3
- import React , { PureComponent } from 'react' ;
3
+ import React from 'react' ;
4
4
import type { Node } from 'react' ;
5
5
import { View } from 'react-native' ;
6
6
@@ -22,42 +22,40 @@ type Props = $ReadOnly<{|
22
22
isFetching : boolean ,
23
23
| } > ;
24
24
25
- export default class SearchMessagesCard extends PureComponent < Props > {
26
- render ( ) : Node {
27
- const { isFetching, messages } = this . props ;
25
+ export default function SearchMessagesCard ( props : Props ) : Node {
26
+ const { narrow, isFetching, messages } = props ;
28
27
29
- if ( isFetching ) {
30
- // Display loading indicator only if there are no messages to
31
- // display from a previous search.
32
- if ( ! messages || messages . length === 0 ) {
33
- return < LoadingIndicator size = { 40 } /> ;
34
- }
35
- }
36
-
37
- if ( ! messages ) {
38
- return null ;
28
+ if ( isFetching ) {
29
+ // Display loading indicator only if there are no messages to
30
+ // display from a previous search.
31
+ if ( ! messages || messages . length === 0 ) {
32
+ return < LoadingIndicator size = { 40 } /> ;
39
33
}
34
+ }
40
35
41
- if ( messages . length === 0 ) {
42
- return < SearchEmptyState text = "No results" /> ;
43
- }
36
+ if ( ! messages ) {
37
+ return null ;
38
+ }
44
39
45
- return (
46
- < View style = { styles . results } >
47
- < MessageList
48
- initialScrollMessageId = {
49
- // This access is OK only because of the `.length === 0` check
50
- // above.
51
- messages [ messages . length - 1 ] . id
52
- }
53
- messages = { messages }
54
- narrow = { this . props . narrow }
55
- showMessagePlaceholders = { false }
56
- // TODO: handle editing a message from the search results,
57
- // or make this prop optional
58
- startEditMessage = { ( ) => undefined }
59
- />
60
- </ View >
61
- ) ;
40
+ if ( messages . length === 0 ) {
41
+ return < SearchEmptyState text = "No results" /> ;
62
42
}
43
+
44
+ return (
45
+ < View style = { styles . results } >
46
+ < MessageList
47
+ initialScrollMessageId = {
48
+ // This access is OK only because of the `.length === 0` check
49
+ // above.
50
+ messages [ messages . length - 1 ] . id
51
+ }
52
+ messages = { messages }
53
+ narrow = { narrow }
54
+ showMessagePlaceholders = { false }
55
+ // TODO: handle editing a message from the search results,
56
+ // or make this prop optional
57
+ startEditMessage = { ( ) => undefined }
58
+ />
59
+ </ View >
60
+ ) ;
63
61
}
0 commit comments