This is documentation for Stream Chat React Native SDK v5, which is nolonger actively maintained. For up-to-date documentation, see the latest version (v6).

CreatePollContext

The CreatePollContext is provided by the CreatePoll component. If you are not familiar with React Context API, please read about it on React docs.

The CreatePollContext needs to be used within the Channel component as it depends on the MessageInputContext which is added by it.

Basic Usage

The CreatePollContext can be consumed by any of the child components of Channel as following:

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

const value = useContext(CreatePollContext);

Alternatively, you can also use the useCreatePollContext hook provided by library to consume CreatePollContext.

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

const value = useCreatePollContext();

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

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.

It expects to receive an argument that conforms to the CreatePollData type that can be found here.

Type
(pollData: CreatePollData) => Promise<void>

createPollOptionHeight

A property used to define the height of the poll options in the CreatePollContent draggable list. The items can have a constant and equal height only and this should only be used if custom theming implies that the static height of the items changes. Has no effect if a custom UI for CreatePollContent is provided.

Type
number

© Getstream.io, Inc. All Rights Reserved.