A component that renders at the top of the list. Can be used to render a button that loads data.
The input component. The Input component is often used here
The component to render when the messages
array is empty
The component to render when old messages
are being loaded. Defaults to an ActivityIndicator
Determines if the list should animate messages into view
As the component is pure, this can be used to force a re-render. Often used when derived components require the header and footer callbacks to re-run.
The hint that is passed to the Input. Can be set to null
to remove the input bar
The length of the messages
array. This can be set explicitly to force a re-render of the Chat
. Usually, this
isn't needed as the component does a check of the length after the onSend
/onLoad
/etc functions run (which
often update the messages array)
The percentage threshold to use when older messages should automatically be loaded. Can be set to 0
to prevent
automatic invoking of onLoad
. The Chat#load
function can be used to explicitly invoke onLoad
The list of messages. The message at the start of the array is shown first.
The Chat
only does a shallow comparison of the messages property. To force a re-render set the length
property as well. By default, after the onSend
/onLoad
/etc callbacks the length of the array is checked to see
if it has changed.
The unique user identification value for this chat
Invoked when the chat list receives user input
the input from the user
a message where the user input has been converted into the typed message
Invoked when more historical messages should be loaded. This occurs on mount and then when the user has
scrolled back through the list of messages. The loadThreshold
property can be used to customise when the
function gets invoked. It can also be set to 0
to prevent automatic loading and the explicit Chat#load
function can be used to invoke this callback.
Performs rendering of a message. The user
property can be used to determine if the message is from the current
user by comparing it with the user
property set on the component.
the message data to render
the index of the message that is being rendered in the messages
array. 0
is the current message,
increasing values are historical messages
the state of the chat messages
a rendered element to display
Invoked when the message is to be sent. Usually this unshifts the message into the messages array.
the converted, fully formed, sent message
the raw user input that was used to create the message
Invoked when the translation starts. Will be invoked with the size of the incoming message
the starting translation value
Invoked when the translation ends
the ending translation value. Will be undefined
if the animation was cancelled
A component that renders at the bottom of the list, above the user input. Can be used to provide suggested inputs values. The Suggestions component is often used here