React
Zero has built-in support for React. Here’s what basic usage looks like:
import {useQuery} from "@rocicorp/zero/react";
function IssueList() {
const z = useZero();
let issueQuery = z.query.issue
.related('creator')
.related('labels')
.limit(100);
const userID = selectedUserID();
if (userID) {
issueQuery = issueQuery.where('creatorID', '=', userID);
}
const [issues, issuesDetail] = useQuery(issueQuery);
return <div>{issuesDetail.type === 'complete' ? 'Complete results' : 'Partial results'}</div>
<div>{issues.map(issue => <IssueRow issue={issue} />)}</div>
}
Complete quickstart here: