Add initialText prop (#1104)

This commit is contained in:
Marek
2019-01-28 13:10:11 +01:00
committed by Xavier Carpentier
parent 9db9d64775
commit a4fd557ce2

View File

@@ -414,9 +414,10 @@ class GiftedChat extends React.Component {
this.setMaxHeight(layout.height);
const newComposerHeight = this.props.minComposerHeight;
const newMessagesContainerHeight = this.getMessagesContainerHeightWithKeyboard(newComposerHeight);
const initialText = this.props.initialText || '';
this.setState({
isInitialized: true,
text: this.getTextFromProp(''),
text: this.getTextFromProp(initialText),
composerHeight: newComposerHeight,
messagesContainerHeight: this.prepareMessagesContainerHeight(newMessagesContainerHeight),
});
@@ -572,6 +573,7 @@ GiftedChat.defaultProps = {
GiftedChat.propTypes = {
messages: PropTypes.arrayOf(PropTypes.object),
text: PropTypes.string,
initialText: PropTypes.string,
placeholder: PropTypes.string,
messageIdGenerator: PropTypes.func,
user: PropTypes.object,