Skip to content
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

Closed
Johnne25 opened this issue Feb 10, 2021 · 3 comments
Closed

Unable to use onClick event for Conversation #14

Johnne25 opened this issue Feb 10, 2021 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@Johnne25
Copy link

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.

@supersnager
Copy link
Contributor

@Johnne25
Thank you for your question.

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.

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})}>

Your Demo of the 4 conversation windows is great. Providing the source code for that would probably answer most of the questions I have.

To be honest this demo is a little mess ;) And it's not a good example.
But we are working now on two new things:

  1. New full-size demo with almost all available features.
  2. Some tutorials and about how to write a real application.

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.

@supersnager supersnager self-assigned this Feb 11, 2021
@supersnager supersnager added the question Further information is requested label Feb 11, 2021
@Johnne25
Copy link
Author

Thanks, your suggested worked perfectly

@supersnager
Copy link
Contributor

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.

Here is the library mentioned: https://github.com/chatscope/use-chat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants