import { Channel, useMessageContext } from "stream-chat-react-native";
import { View } from "react-native";
const CustomMessageSpacer = () => {
const { alignment } = useMessageContext();
return <View style={{ flex: alignment === "left" ? 1 : 0.25 }} />;
};
<Channel MessageSpacer={CustomMessageSpacer} />;This is beta documentation for Stream Chat React Native SDK v9. For the latest stable version, see the latest version (v8)
.
MessageSpacer
MessageSpacer is an optional prop-less override slot inside the outer message row in MessageList.
If you do not provide a MessageSpacer override through Channel, nothing is rendered. The SDK does not export a built-in default MessageSpacer component.
Best Practices
- Use
MessageSpacerfor layout spacing or structure, not message content rendering. - Prefer
MessageSpacerover replacing the fullMessageItemViewwhen you only need row-level whitespace. - Read message state from
useMessageContext()inside the component instead of expecting props. - Keep spacer components lightweight to avoid affecting list performance.
- Return
nullwhen you do not need custom spacing.
Props
MessageSpacer does not receive props.
If you need message state such as alignment, read it from useMessageContext().