Skip to content

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

Open

Description

@Frajdi

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

Activity

  1. JosephReece commented on Jul 16, 2024

    @JosephReece

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions