This is beta documentation for Stream Chat React Native SDK v9. For the latest stable version, see the latest version (v8) .

CreatePollContentContext

CreatePollContentContext is provided by CreatePoll. If you are not familiar with the React Context API, see the React docs.

CreatePollContentContext must be used within Channel because it depends on MessageInputContext provided there.

Best Practices

  • Use useCreatePollContentContext inside Channel-scoped poll creation flows only.
  • Use closePollCreationDialog to cleanly dismiss the UI.
  • Keep creation UI responsive; avoid heavy logic in render.
  • Treat context values as the source of truth for poll draft state.

Basic Usage

Consume CreatePollContentContext in any child of Channel:

import { useContext } from "react";
import { CreatePollContentContext } from "stream-chat-react-native";

const value = useContext(CreatePollContentContext);

Alternatively, use the useCreatePollContentContext hook.

import { useCreatePollContentContext } from "stream-chat-react-native";

const value = useCreatePollContentContext();

Value

sendMessage

Sends a composed message within MessageInput component to channel. This function is attached to onPress handler of SendButton. The message optimistically gets added to message list UI first, before actually making API call to server. During this intermediate stage, MessageStatus component will display an indicator for "pending" state.

Type
Function

The function takes an object as a parameter with the following properties:

ParameterDescription
localMessageContains the message data that will be shown in the UI immediately
messageContains the data that will be sent to the backend
optionsContains options for sending/updating the message

closePollCreationDialog

A method that will be used as a callback whenever the default CreatePoll component back button is pressed in the header. Unless used, it will have no effect if the default CreatePollContent is overridden.

Type
() => void

createAndSendPoll

A method that will be used as a callback whenever send button is clicked on the CreatePoll modal. If a custom UI is used for CreatePollContent, it can be used as an out-of-the-box method to create and send a poll to the MessageList.

Type
() => Promise<void>

createPollOptionGap

Vertical gap between poll options in the poll creation screen's draggable list. Should only be used if custom theming changes the spacing of items. Has no effect if a custom UI for CreatePollContent is provided.

TypeDefault
number8