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
Unable to use onClick event for Conversation #14
Comments
@Johnne25
You are not doing anything wrong :) And you have right I should add some more documentation about callbacks (and I will #15 ). All not documented properties in components are passed down to the main HTML element of the component (unless the documentation state directly otherwise). So your onClick callback is assigned to: <div class="cs-conversation"> But, this library has nothing to do with your data - it's a UI library. Therefore, I try to give the user the greatest possible freedom and control over their data. Now if you need to pass your business data like conversation id to the callback you can pass it in this way: <Conversation key={con${this.props.conversations[index].id}} onClick={() => this.conversationClick(con${this.props.conversations[index].id})}>
To be honest this demo is a little mess ;) And it's not a good example.
Please be patient, we have "a little" work to do with this. It will be available soon. BTW: I'm planning to do an additional library for handling chat logic (like grouping messages, changing handling conversations, et.c) to allow build chat apps with small effort and faster. |
Thanks, your suggested worked perfectly |
Here is the library mentioned: https://github.com/chatscope/use-chat |
I am 100% sure that I am doing something wrong, but I can't seem to find any documentation to describe the use of events for the components.
I track the 'selectedConversationId' as a state on the component class.
When the user click the conversation component I need fire an onClick event so I can update the state property, which sould trigger a rerender. Which would use the 'active' tag for that conversation component.
I am using it like this:
<Conversation key={
con${this.props.conversations[index].id}
} onClick={this.conversationClick}>The conversationClick() method is called, however the parameter passed to the method give no indication on what converstation was clicked. So, I can't determine what is my new 'selectedConverstationId'.
Your Demo of the 4 conversation windows is great. Providing the source code for that would probably answer most of the questions I have.
The text was updated successfully, but these errors were encountered: