Info:
This is documentation for Stream Chat React Native SDK v8, which is no longer actively maintained. For up-to-date documentation, see the latest version (v9).

PollContext

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

PollContext must be used within Channel because it depends on values provided there.

Best Practices

  • Use usePollContext inside Channel-scoped poll components only.
  • Treat poll and message as read-only UI state.
  • Avoid duplicating poll state in local component state.
  • Handle missing or stale poll data gracefully.
  • Keep poll UI logic lightweight to avoid list re-renders.

Basic Usage

Consume PollContext in any child of Channel:

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

const value = useContext(PollContext);

Alternatively, use the usePollContext hook.

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

const value = usePollContext();

Value

message

Message object.

Type
Message type

poll *

An instance of the Poll class containing reactive state.

It is used by the underlying usePollContext, usePollStateStore and usePollState hooks to provide us with the reactive Poll state.

Note:

If you need the Poll instance you may get it from client.polls.fromState(pollId).

Type
object
Add Chat to my app: getstream.io/SKILL.md

The fastest way to build with Stream. Start a new project or improve an existing one. Full CLI and documentation integration out of the box.


Ask your agent:

/stream Build me a Social App with Feeds and Moderation.
/stream Any livestream calls running?
/stream Chat React Native v8: <Your Question>