FaridSafi / react-native-gifted-chat

💬 The most complete chat UI for React Native
https://gifted.chat
MIT License
13.54k stars 3.56k forks source link

Text prop default input cleared on initial render #603

Closed ArneMis closed 5 years ago

ArneMis commented 7 years ago

When rendering a Giftedchat component with text property linked to a local state will result in the clearing of the state value when rendering for the first time.

create a component which includes giftedchat in the render method:

constructor(props, context) { super(props, context); this.state = { message:"test" }; }

setCustomText = (newMessage) => { this.setState({ ...this.state, message:newMessage }); }

.... <GiftedChat text={this.state.message} onInputTextChanged={(text) => this.setCustomText(text)} ... /> ...

When we put a default message text in the giftedchat, it is overwritten when rendered for the first time. I think the issue is related to the "notifyInputTextReset" function who resets the inputText and passes it to the onInputTextChanged.

If we do not include the onInputTextChanged method, we are unable to type in the inputbox.

Expected Results

Able to put a default message in the inputText linked the prop "text".

Additional Information

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

RediaUa commented 4 years ago

any progress?

AlexBungiu commented 3 years ago

anyone having the same problem, this seems to fix it