stream-chat-react-native-core 5.12.0-beta.2 → 5.12.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stream-chat-react-native-core",
3
3
  "description": "The official React Native and Expo components for Stream Chat, a service for building chat applications",
4
- "version": "5.12.0-beta.2",
4
+ "version": "5.12.0-beta.3",
5
5
  "author": {
6
6
  "company": "Stream.io Inc",
7
7
  "name": "Stream.io Inc"
@@ -1012,6 +1012,17 @@ const MessageListWithContext = <
1012
1012
  return null;
1013
1013
  };
1014
1014
 
1015
+ // We need to omit the style related props from the additionalFlatListProps and add them directly instead of spreading
1016
+ let additionalFlatListPropsExcludingStyle:
1017
+ | Omit<NonNullable<typeof additionalFlatListProps>, 'style' | 'contentContainerStyle'>
1018
+ | undefined;
1019
+
1020
+ if (additionalFlatListProps) {
1021
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1022
+ const { contentContainerStyle, style, ...rest } = additionalFlatListProps;
1023
+ additionalFlatListPropsExcludingStyle = rest;
1024
+ }
1025
+
1015
1026
  return (
1016
1027
  <View
1017
1028
  style={[styles.container, { backgroundColor: white_snow }, container]}
@@ -1021,7 +1032,11 @@ const MessageListWithContext = <
1021
1032
  CellRendererComponent={
1022
1033
  shouldApplyAndroidWorkaround ? InvertedCellRendererComponent : undefined
1023
1034
  }
1024
- contentContainerStyle={[styles.contentContainer, contentContainer]}
1035
+ contentContainerStyle={[
1036
+ styles.contentContainer,
1037
+ additionalFlatListProps?.contentContainerStyle,
1038
+ contentContainer,
1039
+ ]}
1025
1040
  data={messageList}
1026
1041
  /** Disables the MessageList UI. Which means, message actions, reactions won't work. */
1027
1042
  extraData={disabled || !hasNoMoreRecentMessagesToLoad}
@@ -1049,11 +1064,12 @@ const MessageListWithContext = <
1049
1064
  style={[
1050
1065
  styles.listContainer,
1051
1066
  listContainer,
1067
+ additionalFlatListProps?.style,
1052
1068
  shouldApplyAndroidWorkaround ? styles.invertAndroid : undefined,
1053
1069
  ]}
1054
1070
  testID='message-flat-list'
1055
1071
  viewabilityConfig={flatListViewabilityConfig}
1056
- {...additionalFlatListProps}
1072
+ {...additionalFlatListPropsExcludingStyle}
1057
1073
  />
1058
1074
  {!loading && (
1059
1075
  <>
@@ -43,6 +43,7 @@ exports[`Thread should match thread snapshot 1`] = `
43
43
  "flexGrow": 1,
44
44
  "paddingBottom": 4,
45
45
  },
46
+ undefined,
46
47
  Object {},
47
48
  ]
48
49
  }
@@ -180,6 +181,7 @@ exports[`Thread should match thread snapshot 1`] = `
180
181
  },
181
182
  Object {},
182
183
  undefined,
184
+ undefined,
183
185
  ],
184
186
  ]
185
187
  }
@@ -1,22 +1,25 @@
1
- import { useCallback, useEffect, useRef } from 'react';
1
+ import { useEffect, useRef } from 'react';
2
2
  import { AppState, AppStateStatus } from 'react-native';
3
3
 
4
4
  export const useAppStateListener = (onForeground?: () => void, onBackground?: () => void) => {
5
5
  const appStateRef = useRef(AppState.currentState);
6
- const handleAppStateChange = useCallback(
7
- (nextAppState: AppStateStatus) => {
6
+ const onForegroundRef = useRef(onForeground);
7
+ const onBackgroundRef = useRef(onBackground);
8
+
9
+ // setting refs to avoid passing the functions as dependencies to useEffect
10
+ onForegroundRef.current = onForeground;
11
+ onBackgroundRef.current = onBackground;
12
+
13
+ useEffect(() => {
14
+ const handleAppStateChange = (nextAppState: AppStateStatus) => {
8
15
  const prevAppState = appStateRef.current;
9
16
  if (prevAppState.match(/inactive|background/) && nextAppState === 'active') {
10
- onForeground?.();
17
+ onForegroundRef.current?.();
11
18
  } else if (prevAppState === 'active' && nextAppState.match(/inactive|background/)) {
12
- onBackground?.();
19
+ onBackgroundRef.current?.();
13
20
  }
14
21
  appStateRef.current = nextAppState;
15
- },
16
- [onBackground, onForeground],
17
- );
18
-
19
- useEffect(() => {
22
+ };
20
23
  const subscription = AppState.addEventListener('change', handleAppStateChange);
21
24
 
22
25
  return () => {
@@ -28,5 +31,5 @@ export const useAppStateListener = (onForeground?: () => void, onBackground?: ()
28
31
  AppState.removeEventListener('change', handleAppStateChange);
29
32
  }
30
33
  };
31
- }, [handleAppStateChange]);
34
+ }, []);
32
35
  };
package/src/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "5.12.0-beta.2"
2
+ "version": "5.12.0-beta.3"
3
3
  }