New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve typings to allow for generic messages #1025

merged 6 commits into from Dec 4, 2018


None yet
3 participants

hammadj commented Nov 30, 2018

This allows users to define their own message types with additional fields, eg:

import { IMessage } from 'react-native-gifted-chat';

export interface Message extends IMessage {
  file?: string;
  error?: string;
  customType?: string;
  isPlaceholder?: boolean;
  isSelected?: boolean;
  data?: MessageData;

Then, they can optionally use this when using custom render functions as follows:

renderBubble = (props: BubbleProps<Message>) => {
    // ...

Also fixed the prop types for renderMessageImage and renderMessageText, as well as updating typings to use the new React Native StyleProp type.


This comment has been minimized.

codecov bot commented Nov 30, 2018

Codecov Report

Merging #1025 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1025   +/-   ##
  Coverage   42.97%   42.97%           
  Files          20       20           
  Lines         498      498           
  Branches      108      108           
  Hits          214      214           
  Misses        214      214           
  Partials       70       70

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 11548ed...ff8013e. Read the comment docs.

hammadj added some commits Nov 30, 2018

export type IMessage = IChatMessage | ISystemMessage;
export type IChatMessage = IMessage

This comment has been minimized.


hammadj Dec 2, 2018


For backwards compatibility so users using IChatMessage instead of IMessage don't have to refactor their types

@sibelius sibelius merged commit 679e338 into FaridSafi:master Dec 4, 2018

3 checks passed

ci/circleci Your tests passed on CircleCI!
codecov/project 42.97% remains the same compared to 11548ed
continuous-integration/travis-ci/pr The Travis CI build passed

PaperMonster added a commit to shobshop/react-native-gifted-chat that referenced this pull request Dec 7, 2018

Merge branch 'master' of…

* 'master' of (36 commits)
  Improve typings to allow for generic messages (FaridSafi#1025)
  pending tick (FaridSafi#1024)
  add send video support  (FaridSafi#1010)
  Show the username on the message (FaridSafi#929)
  Update (FaridSafi#964)
  Update (FaridSafi#996)
  Error in FlatList with latest react-native version
  fix imageStyle?: ViewStyle
  Update index.d.ts
  Update index.d.ts
  Update index.d.ts
  Update index.d.ts
  Improved typings (FaridSafi#940)
  Change component interface name ISystemChat to SystemChat (FaridSafi#995)
  Add prop to customise to Text style of timestamps (FaridSafi#942)
  Fix MessageContainer keyboard avoiding when messages array is empty (FaridSafi#898)

# Conflicts:
#	src/MessageContainer.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment