mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-29 18:26:34 +02:00
12 lines
358 B
TypeScript
12 lines
358 B
TypeScript
import { GetPollResponse } from "api-client/get-poll";
|
|
import React from "react";
|
|
|
|
export const PollContext = React.createContext<GetPollResponse | null>(null);
|
|
|
|
export const usePoll = () => {
|
|
const context = React.useContext(PollContext);
|
|
if (!context) {
|
|
throw new Error("Tried to get poll from context but got undefined");
|
|
}
|
|
return context;
|
|
};
|