diff --git a/example-expo/App.js b/example-expo/App.js index 3a3b4b6..fba9990 100644 --- a/example-expo/App.js +++ b/example-expo/App.js @@ -80,6 +80,7 @@ export default class App extends Component { messages={this.state.messages} onSend={this.onSend} renderCustomView={CustomView} + keyboardShouldPersistTaps="never" user={{ _id: 1, }} diff --git a/package.json b/package.json index 1327f8e..22c181e 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,6 @@ }, "dependencies": { "@expo/react-native-action-sheet": "^1.0.1", - "hash-sum": "1.0.2", "moment": "^2.19.0", "react-native-communications": "2.2.1", "react-native-lightbox": "^0.7.0", diff --git a/src/Avatar.js b/src/Avatar.js index ad4dfc9..c34fdaf 100644 --- a/src/Avatar.js +++ b/src/Avatar.js @@ -35,7 +35,7 @@ const styles = { }), }; -export default class Avatar extends React.Component { +export default class Avatar extends React.PureComponent { renderAvatar() { if (this.props.renderAvatar) { diff --git a/src/Bubble.js b/src/Bubble.js index 704310a..0fd2d93 100644 --- a/src/Bubble.js +++ b/src/Bubble.js @@ -11,7 +11,7 @@ import Color from './Color'; import { isSameUser, isSameDay } from './utils'; -export default class Bubble extends React.Component { +export default class Bubble extends React.PureComponent { constructor(props) { super(props); diff --git a/src/Message.js b/src/Message.js index 58582e0..1ea473e 100644 --- a/src/Message.js +++ b/src/Message.js @@ -1,4 +1,4 @@ -/* eslint no-use-before-define: ["error", { "variables": false }], react-native/no-inline-styles: 0 */ +/* eslint react-native/no-inline-styles: 0 */ import PropTypes from 'prop-types'; import React from 'react'; @@ -11,6 +11,27 @@ import Day from './Day'; import { isSameUser, isSameDay } from './utils'; +const styles = { + left: StyleSheet.create({ + container: { + flexDirection: 'row', + alignItems: 'flex-end', + justifyContent: 'flex-start', + marginLeft: 8, + marginRight: 0, + }, + }), + right: StyleSheet.create({ + container: { + flexDirection: 'row', + alignItems: 'flex-end', + justifyContent: 'flex-end', + marginLeft: 0, + marginRight: 8, + }, + }), +}; + export default class Message extends React.PureComponent { getInnerComponentProps() { @@ -88,27 +109,6 @@ export default class Message extends React.PureComponent { } -const styles = { - left: StyleSheet.create({ - container: { - flexDirection: 'row', - alignItems: 'flex-end', - justifyContent: 'flex-start', - marginLeft: 8, - marginRight: 0, - }, - }), - right: StyleSheet.create({ - container: { - flexDirection: 'row', - alignItems: 'flex-end', - justifyContent: 'flex-end', - marginLeft: 0, - marginRight: 8, - }, - }), -}; - Message.defaultProps = { renderAvatar: undefined, renderBubble: null, diff --git a/src/MessageContainer.js b/src/MessageContainer.js index f799958..d1015cb 100644 --- a/src/MessageContainer.js +++ b/src/MessageContainer.js @@ -11,7 +11,6 @@ import PropTypes from 'prop-types'; import React from 'react'; import { FlatList, View, StyleSheet, Platform } from 'react-native'; -import sum from 'hash-sum'; import LoadEarlier from './LoadEarlier'; import Message from './Message'; @@ -77,9 +76,6 @@ export default class MessageContainer extends React.PureComponent { previousMessage, nextMessage, position: item.user._id === this.props.user._id ? 'right' : 'left', - hash: sum( - `${item.body ? item.body.length : 0}${JSON.stringify(item.attributes)}${previousMessage._id}${nextMessage._id}`, - ), }; if (this.props.renderMessage) { diff --git a/src/MessageText.js b/src/MessageText.js index 1f73e4e..e50425f 100644 --- a/src/MessageText.js +++ b/src/MessageText.js @@ -8,7 +8,7 @@ import Communications from 'react-native-communications'; const WWW_URL_PATTERN = /^www\./i; -export default class MessageText extends React.Component { +export default class MessageText extends React.PureComponent { constructor(props) { super(props); @@ -62,17 +62,9 @@ export default class MessageText extends React.Component { } render() { - const linkStyle = StyleSheet.flatten([ - styles[this.props.position].link, - this.props.linkStyle[this.props.position], - ]); + const linkStyle = StyleSheet.flatten([styles[this.props.position].link, this.props.linkStyle[this.props.position]]); return ( - +