Detaysoft / react-chat-elements

Reactjs chat elements chat UI, react chat components
MIT License
1.2k stars 217 forks source link

messageBox props asking so many props #218

Open praveengopu0105 opened 6 months ago

praveengopu0105 commented 6 months ago

i didnt know while working with typescript messageBox component asking so many required props but in documentation it having less props so when i just copy paste it is showing props are missing

bhattiasad99 commented 4 months ago

Did you resolve this? Im facing the same issue

Sorbuscorp commented 4 months ago

I bypassed this problem with Partial type. In code it may looks like:

function message(id:string, text:string, position: string):Partial<MessageType>{
    return {
        position: position,
        type: 'text',
        text: text,
        // date: new Date(),
        title: position=="left" ? "AI" : "You" ,
        id: id,
        titleColor:"black",
        forwarded: false,
        focus: false,
        removeButton : false,
        replyButton : false,
        //status : "",
        notch : true,
        retracted : false,
    }
}

//example
let messages = [message("0", loremIpsum(), "right") ...];
<MessageList
                referance={messageListReferance}
                lockable={true}
                toBottomHeight={'50%'}
                dataSource={messages as MessageType[]}
            />

You can delete any fields in message function and it must be correct.