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

Is there any way to render a custom component inside the chat message? #215

Open
Frajdi opened this issue Feb 16, 2024 · 1 comment
Open

Comments

@Frajdi
Copy link

Frajdi commented Feb 16, 2024

I would like something like this

<MessageList
            className="message-list"
            dataSource={messages}
            renderMessage={(message) => {
                if(isCode(messagge.text)){
                     return <CodeSnippet code={message.text}/>
                }else{
                    return <p>{message.text}</p>
                }}
/>
@JosephReece
Copy link

Just found out you can use the text property to support under courtesy of @last-Programmer so your code may look like this:

<MessageList
  className='message-list'
  dataSource={messages.map(message => (
    isCode(message.text) ? (
      {...message, text: <CodeSnippet code={message.text}/>}
    ) : (
      {...message, text: <p>{message.text}</p>}
    )
/>

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

No branches or pull requests

2 participants