import { useMatrix, useRoomList } from '@rn-matrix/core'
...
// within your component
const { isReady, isSynced } = useMatrix();
const { roomList, inviteList, updateLists } = useRoomList();
if (!isReady || !isSynced) // return a loader
return (
<FlatList data={roomList} renderItem={...} />
)
Using UI
import { RoomList } from '@rn-matrix/ui'
...
function RoomListView() {
const { isReady, isSynced } = useMatrix(); // you should still wait for these
const onRowPress = (item) => {}
if (!isReady || !isSynced) // return a loader
return <RoomList onRowPress={onRowPress} />
}
Join room
Be sure to update the lists after joinRoom resolves.
updates is an array of messages that are deleted, edited, etc and therefore should be re-rendered in the view. Using this, you can memoize your MessageItem, reducing the number of useless re-renders on your screen.
import { useTimeline } from '@rn-matrix/core'
...
export default function MessageView() {
// Get "room" from navigation params, from clicking on it in the inbox
return <MessageList room={room} />
}
Send message to a room
Send message
Text
For automatic conversion of markdown to html:
rnm.sendTextMessage(roomId, content) // content is your markdown string
For basic sending (no alterations made):
rnm.getClient().sendTextMessage(roomId, content)
Image or Video
rnm.sendMediaMessage(roomId, content, type)
In this case, content is something that is received directly from something like ImagePicker.
This is what's happening in /ui in the component behind the scenes. Render rooms and invites however you'd like. inviteList is a list of rooms you are not a part of yet, but have been invited to.
updateLists is a function which refreshes the lists, usually in the event of an invite rejection / acceptance.
The component will show a simple inbox. However, you can override what it looks like by using the prop renderListItem. Read more at .
View the Room method
To see an implementation of this including fetching previous messages, handling touches on the screen, rendering a typing indicator, etc, you can see that .
View the docs on to see what you can do for handling touches (onPress, onLongPress).