-
Couldn't load subscription status.
- Fork 353
Upgrade helper
-
Peer dependency of
react-native-image-pickerhas been changed toreact-native-image-crop-pickerfor following two reasons:- To fix the issue with image uploads - https://github.com/GetStream/stream-chat-react-native/issues/241
-
react-native-image-pickerdidn't offer any option for image compression, which slows down uploads of heavy images.
So you will need to install this new dependency on app level.
yarn remove react-native-image-picker # Remove previous dependency if you don't need it yarn add react-native-image-crop-picker cd ios && pod install && cd ..
There are few additional changes that you need to do separately for iOS and android
- You will need to install https://github.com/LinusU/react-native-get-random-values and add this line
import 'react-native-get-random-values';to yourindex.js
- Expo 39 is now the lowest supported version from 2.x.x
This library has been moved to full typescript. Please check Typescript doc for details. This change from a maintained definition file gives more accurate types but also has resulted in many type names changing. The 2.x.x type definitions should be used as the source of truth for the correct type names and typings.
-
Changes to Keyboard functionality: Internally we use
KeyboardCompatibleViewcomponent to sync Channel height according to keyboard state. As part of 1.3.x we updated have the implementation forKeyboardCompatibleView. Updated KeyboardCompatibleView's implentation is mostly same asKeyboardAvoidingView, with few additional fixes for app state (background | foreground). And thus, following props on Channel component won't be supported anymore:- keyboardDismissAnimationDuration
- keyboardOpenAnimationDuration
Following new props have been introduced on Channel component. They are the same props accepted by KeyboardAvoidingView of react-native.
- keyboardBehavior ['height' | 'position' | 'padding']
- keyboardVerticalOffset
-
All the components were moved from class based components to functional components, gradually as part of 1.x.x. This caused some breaking changes on
ChannelListcomponent's custom event handlers. ChannelList component has its own default logic for handling different types of events. Although these default event handlers can still be overridden by providing custom prop functions to the ChannelList component. Custom logic can be provided for the following events.-
onAddedToChanneloverridesnotification.added_to_channeldefault -
onChannelDeletedoverrideschannel.deleteddefault -
onChannelHiddenoverrideschannel.hiddendefault -
onChannelTruncatedoverrideschannel.truncateddefault -
onChannelUpdatedoverrideschannel.updateddefault -
onMessageNewoverridesnotification.message_newdefault -
onRemovedFromChanneloverridesnotification.removed_from_channeldefaultThese props were already present in 0.x.x as well. Breaking change is on the parameters of these event handlers. In 0.x.x, these event handlers used to have
thisas its first argument, which was reference ChannelList component (class based).From 1.3.x, these handlers will accept following params:
-
1st argument:
setChannelsreference to theuseStatehook that sets thechannelsin the React Native FlatList -
2nd argument:
eventobject returned by the StreamChat instance
-
-
Similar breaking change was introduced in
MessageSimplecomponent as well. For example, if you wish to override the SDK's standard long press behavior on a message, theonLongPressoronPressfunction passed in toMessageSimpleno longer takes thethiscomponent reference as it's first argument. The message and the event object become the first and second arguments, respectively.
-
If you are using
withChannelContextfunction inside your app, then you may want to pay attention for context related changes. We have split theChannelContextinto three separate contexts to further modularize the code and reduce renders as items in context change. The following contexts now contain the following values, previously all held within theChannelContext:-
ChannelContext:channel,disabled,EmptyStateIndicator,error,eventHistory,lastRead,loading,LoadingIndicator,markRead,members,read,setLastRead,typing,watcherCount,watchers -
MessagesContext:Attachment,clearEditingState,editing,editMessage,emojiData,hasMore,loadingMore,loadMore,Message,messages,removeMessage,retrySendMessage,sendMessage,setEditingState,updateMessage -
ThreadContext:closeThread,loadMoreThread,openThread,thread,threadHasMore,threadLoadingMore,threadMessages
-
- The
renderTextfunction utilized in theMessageTextContainercomponent now accepts a single object containingmarkdownRules,markdownStyles, andmessage. Previously each value was a separate function parameter - Markdown use simple-markdown to tokenize the entire text within a
messageobject - That tokenized text is then passed through rendering markdownRules and given associated markdownStyles
- Override any or all of the rendering rules by passing in your own
markdownRules - Override any or all of the styles for markdown renders by passing in your own
markdownStyleswhich have typescript definitions shown here
- The
styleprop to override the theme on components has been removed. By default the theme is provided via thestyleprop on theChatcomponent. To modify the theme at the component level the component should be wrapped in an additionalThemeProvider, which should be supplied the modifications via the propstyle. These theme modifications will be merged with parent themes includingChatfor encompassed child components. This change applies to modifying style on sent vs. received messages, a common use case for theme overrides. For this case it is suggested that the defaultChattheme have the styling for the more common message type, often received messages for group chats, and the other message type(s) be wrapped in their own theme providers.
if (isMyMessage(message)) {
return (
<ThemeProvider style={sentMessageStyles}>
<MessageSimple {...props} />
</ThemeProvider>
);
} else {
return (
<MessageSimple {...props} />
);
}The shift to context hooks, removal of Higher Order Components, and addition of TypeScript in 2.x.x results in many props changing. The types should be used as the source of truth for the correct props.
Channel
- added
additionalKeyboardAvoidingViewPropsprop to allow custom keyboard props - removed
clientas it is now provided via context
ChannelListMessenger
- remove
setActiveChannelprop
ChannelPreviewMessenger
- renamed the
latestMessageprop tolatestMessagePreview. This name change is more semantic to what the prop does and reduces confusion with thelastMessageprop
FileIploadPreview
- dropped support for the
fileUploadPreview.dismissTexttheme value - added support for
fileUploadPreview.dismiss,fileUploadPreview.dismissImage, andfileUploadPreview.imageContainertheme values
MessageList
-
Dropped support for the
MessageListcomponent'sonMessageTouchprop. Please use theonPressprop on theMessageSimplecomponent to perform an action on touch of a message. -
Dropped support for the following
MessageListprops:-
dateSeparator(use DateSeparator instead) -
headerComponent(use HeaderComponent instead)
-
-
The
MessageSystemprop goes onMessageListnow and not other components that previously shared theMessageUIComponentPropstype.
MessageSimple
- Dropped support for the
Messagecomponent'sreadOnlyprop. Please use thedisabledvalue from theChannelContextinstead.
MessageContent
- removed
retrySendMessageprop in favor ofretrySendMessagewithinMessagesContext
MessageInput
- remove
parentprop toparent_idas it needs to be just an id string instead of the entire parent object - add
setInputRefprop to actually allow forwarding of the TextInput ref controls
MessageSystem
- add
formatDateprop to allow custom date formatting
Thread
- remove
threadandthreadMessagesas these are now supplied via context
- 1.3.x replaced native dependency support for react-native-image-picker in favor of react-native-image-crop-picker for multi-image selection capabilities
-
0.2.x added support for react native 0.60. Dependencies like
react-native-image-picker,react-native-document-pickerandnetinfohave been taken out of hard dependencies and moved to peer dependencies and thus will have to be installed manually on consumer end (Reference) -
React Native 0.60 came with auto-linking functionality that means if some native libraries are linked manually before the upgrade, they will have to be unlinked, so that React Native can auto-link them (Reference)
react-native unlink react-native-image-picker react-native unlink react-native-document-picker react-native unlink @react-native-community/netinfo -
React Native 0.60 has been migrated over to AndroidX. In the current context, dependencies such as
react-native-document-pickerand (if you are usingreact-navigation)react-native-gesture-handler,react-native-reanimateddon't have AndroidX support. But an excellent tool named jetifier is quite useful to patch these dependencies with AndroidX support. -
CocoaPods are not part of React Native's iOS project (ref). Thus make sure to install all the pod dependencies.
cd ios && pod install && cd ..