Skip to content

Commit 6024adc

Browse files
committed
fix: some more prettier errors
1 parent d85338d commit 6024adc

File tree

3 files changed

+41
-21
lines changed

3 files changed

+41
-21
lines changed

examples/SampleApp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"start": "react-native start",
1313
"test": "jest",
1414
"lint": "eslint .",
15-
"lint-fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
15+
"lint-fix": "eslint . --fix",
1616
"extract-changelog": "FILTER_PATH='examples/SampleApp' TAG_FORMAT=$npm_package_name'@v${version}' node ../../release/extract-changelog.js",
1717
"bootstrap": "yarn install",
1818
"release": "FILTER_PATH='examples/SampleApp' TAG_FORMAT=$npm_package_name'@v${version}' node ../../release/prod",

examples/SampleApp/src/screens/ChannelListScreen.tsx

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import React, { useCallback, useMemo, useRef, useState } from 'react';
2-
import { FlatList, StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native';
2+
import {
3+
FlatList,
4+
FlatListProps,
5+
StyleSheet,
6+
Text,
7+
TextInput,
8+
TouchableOpacity,
9+
View,
10+
} from 'react-native';
311
import { useNavigation, useScrollToTop } from '@react-navigation/native';
412
import { ChannelList, CircleClose, Search, useTheme } from 'stream-chat-react-native';
513
import { Channel } from 'stream-chat';
@@ -108,24 +116,33 @@ export const ChannelListScreen: React.FC = () => {
108116
</View>
109117
);
110118

111-
const additionalFlatListProps = useMemo(() => ({
112-
getItemLayout: (_, index) => ({
113-
index,
114-
length: 65,
115-
offset: 65 * index,
119+
const additionalFlatListProps = useMemo<Partial<FlatListProps<Channel<StreamChatGenerics>>>>(
120+
() => ({
121+
getItemLayout: (_: unknown, index: number) => ({
122+
index,
123+
length: 65,
124+
offset: 65 * index,
125+
}),
126+
keyboardDismissMode: 'on-drag',
116127
}),
117-
keyboardDismissMode: 'on-drag',
118-
}), []);
119-
120-
const onSelect = useCallback((channel) => {
121-
navigation.navigate('ChannelScreen', {
122-
channel,
123-
});
124-
}, [navigation]);
125-
126-
const setScrollRef = useCallback( () => (ref: FlatList<Channel<StreamChatGenerics>> | null) => {
127-
scrollRef.current = ref;
128-
}, []);
128+
[],
129+
);
130+
131+
const onSelect = useCallback(
132+
(channel: Channel) => {
133+
navigation.navigate('ChannelScreen', {
134+
channel,
135+
});
136+
},
137+
[navigation],
138+
);
139+
140+
const setScrollRef = useCallback(
141+
() => (ref: FlatList<Channel<StreamChatGenerics>> | null) => {
142+
scrollRef.current = ref;
143+
},
144+
[],
145+
);
129146

130147
if (!chatClient) {
131148
return null;

examples/SampleApp/src/screens/ThreadScreen.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type { RouteProp } from '@react-navigation/native';
1818
import type { StackNavigatorParamList, StreamChatGenerics } from '../types';
1919
import { ThreadState } from 'stream-chat';
2020

21-
const selector = (nextValue: ThreadState) => ({ parentMessage: nextValue.parentMessage } as const);
21+
const selector = (nextValue: ThreadState) => ({ parentMessage: nextValue.parentMessage }) as const;
2222

2323
const styles = StyleSheet.create({
2424
container: {
@@ -40,7 +40,10 @@ const ThreadHeader: React.FC<ThreadHeaderProps> = ({ thread }) => {
4040
const typing = useTypingString();
4141
let subtitleText = thread?.user?.name;
4242
const { parentMessage } =
43-
useStateStore(thread?.threadInstance?.state ?? undefined, selector) || [];
43+
useStateStore(
44+
(thread?.threadInstance as ThreadContextValue<StreamChatGenerics>['threadInstance'])?.state,
45+
selector,
46+
) || {};
4447

4548
if (subtitleText == null) {
4649
subtitleText = parentMessage?.user?.name;

0 commit comments

Comments
 (0)