import {
OverlayProvider,
Chat,
Channel,
CreatePoll,
} from "stream-chat-react-native";
const App = () => {
return (
<OverlayProvider>
<Chat client={client}>
<Channel channel={channel}>
<CreatePoll sendMessage={sendMessage} {...otherOptionalProps} />
</Channel>
</Chat>
</OverlayProvider>
);
};CreatePoll
A component used to render the entirety of the poll creation form. It encapsulates the CreatePollContent component within a CreatePollContext. Needs to be structured inside a Channel component.
The default behaviour of this component is it opening in a React Native Modal. Integrators are highly encouraged to write their own UI for the dialog with the specific options and flexibility they require.
Best Practices
- Render
CreatePollinsideChannelso context and send hooks are available. - Provide a custom dialog UI if you need full control over UX.
- Call
closePollCreationDialogto cleanly dismiss the modal. - Validate poll options before calling
sendMessage. - Keep poll creation UI lightweight to avoid input lag.
General Usage
Props
| Prop | Description | Type |
|---|---|---|
sendMessage | Sends a composed message within MessageComposer component to channel. The message optimistically gets added to the message list UI first, before making the API call. The function takes an object with localMessage, message, and options properties. | function |
closePollCreationDialog | A callback invoked when the default CreatePoll component back button is pressed in the header. Has no effect if the default CreatePollContent is overridden. | () => void |
createPollOptionGap | The gap between poll options in the CreatePollContent draggable list. Only needed if custom theming changes the static height of items. Has no effect if a custom CreatePollContent is provided. Defaults to 8. | number |
onThreadSelect | The height of poll options in the CreatePollContent draggable list. Only needed if custom theming changes the static height of items. Has no effect if a custom CreatePollContent is provided. | number |
CreatePollContent | Custom UI component to render the entire poll creation form. Has access to CreatePollContext values via the useCreatePollContext hook. Defaults to CreatePollContent. | ComponentType |