Configuration options for the sync hook
Object containing sync functions and connection state
This hook handles real-time synchronization of Q&A state across all participants in a room using the Hiyve data message system.
Message Flow:
Owner Responsibilities:
function QAComponent() {
const questionsRef = useRef(new Map());
const [questions, setQuestions] = useState([]);
const {
postQuestion,
answerQuestion,
deleteQuestion,
toggleVote,
pinQuestion,
connected,
} = useQASync({
client,
isOwner,
localUserId: userId,
localUserName: userName,
questionsRef,
onStateUpdate: setQuestions,
});
const handleAsk = (content) => {
const question = postQuestion(content);
if (question) {
setQuestions(prev => [...prev, question]);
}
};
}
Hook for Q&A synchronization via data messages.