This is documentation for the release candidate Stream Chat React Native SDK v7. For the latest stable version, see the latest version (v6).

Migration from 6.x to 7.x

Removal of StreamChatGenerics and introduction of module augmentation

In v7.0.0 and onwards, we’ve decided to refresh our handling of custom typing through the introduction of module augmentation as a replacement of generics.

You can read more about this in our dedicated guide, found here.

Who is affected by this change?

  • Integrators who read custom properties defined by the SDK (such as channel.image)
  • Integrators who have created custom generics for custom properties
  • Integrators who use custom properties without generics (the new system will cause type errors, whereas the old would allow it)

To migrate seamlessly, what you need to do is the following:

  • Remove all instances of StreamChatGenerics
  • Remove all generic type declarations from your code
  • Include a Typescript declaration file, as described here

As an example, if previously you had something like:

// custom-types.ts
type LocalAttachmentType = {
  file_size?: number;
  mime_type?: string;
};
type LocalChannelType = Record<string, unknown>;
type LocalCommandType = string;
type LocalEventType = Record<string, unknown>;
type LocalMessageType = Record<string, unknown>;
type LocalReactionType = Record<string, unknown>;
type LocalUserType = {
  image?: string;
};

type StreamChatGenerics = {
  attachmentType: LocalAttachmentType;
  channelType: LocalChannelType;
  commandType: LocalCommandType;
  eventType: LocalEventType;
  messageType: LocalMessageType;
  reactionType: LocalReactionType;
  userType: LocalUserType;
};

you would now have:

// custom-types.d.ts
import {
  DefaultAttachmentType,
  DefaultChannelType,
  DefaultCommandType,
  DefaultEventType,
  DefaultMemberType,
  DefaultMessageType,
  DefaultPollOptionType,
  DefaultPollType,
  DefaultReactionType,
  DefaultThreadType,
  DefaultUserType,
} from "stream-chat-react-native";

declare module "stream-chat" {
  /* eslint-disable @typescript-eslint/no-empty-object-type */

  interface CustomAttachmentData extends DefaultAttachmentType {
    file_size?: number;
    mime_type?: string;
  }

  interface CustomChannelData extends DefaultChannelType {}

  interface CustomCommandData extends DefaultCommandType {}

  interface CustomEventData extends DefaultEventType {}

  interface CustomMemberData extends DefaultMemberType {}

  interface CustomUserData extends DefaultUserType {
    image?: string;
  }

  interface CustomMessageData extends DefaultMessageType {}

  interface CustomPollOptionData extends DefaultPollOptionType {}

  interface CustomPollData extends DefaultPollType {}

  interface CustomReactionData extends DefaultReactionType {}

  interface CustomThreadData extends DefaultThreadType {}

  /* eslint-enable @typescript-eslint/no-empty-object-type */
}

assuming no custom properties were used without generic declaration.

Please note that as mentioned above, use of properties not belonging to the merged interface will now fail the type-check.

If you really need to keep this behaviour until you are able to merge, please refer to this section in the guide.

However, we strongly advise that you track down and include these types in the declared interfaces.

You may feel free to use our SampleApp’s implementation as inspiration here.

Dependency changes

The following dependencies are the ones changing in the new version or being removed altogether.

Change react-native-document-picker to @react-native-documents/picker

The react-native-document-picker package has been replaced with @react-native-documents/picker in favour of the former not being actively maintained. You can replace it by running the following commands:

yarn remove react-native-document-picker
yarn add @react-native-documents/picker

While we supported both in V6 in order to give our integrators some time to adjust, we are now removing react-native-document-picker entirely.

Removal of deprecated code

In addition to the changes above, we’ve also removed some deprecated code from the SDK.

If your integration relies on this code you will need to adjust accordingly.

Removed ChannelList hooks

With the introduction of the new ChannelManager for ChannelList reactivity we no longer need or use the hooks responsible for listening to events.

If you’ve used these in your specific integration and need them, you may still view them in this commit.

The removed hooks are:

  • useAddedToChannelNotification
  • useChannelDeleted
  • useChannelHidden
  • useChannelMemberUpdated
  • useChannelTruncated
  • useChannelVisible
  • useNewMessage
  • useNewMessageNotification
  • useRemovedFromChannelNotification

Additionally, the useUserPresence has also been removed since reactivity to presence related events has been moved down to ChannelPreview.

© Getstream.io, Inc. All Rights Reserved.