Skip to content

Instantly share code, notes, and snippets.

@evanheckert
evanheckert / use-assignment-ids.ts
Created October 27, 2025 19:12
Get Related IDs for multiple entities
import { and, eq, isUndefined, not, useLiveQuery } from '@tanstack/react-db'
import { useMemo } from 'react'
import { installerDispatchCollection, installerDispatchVehicleDispatchCollection, vehicleDispatchCollection } from '@/db/dispatch'
const finalize = (set: Set<string>) => (set.size ? Array.from(set).sort().join(',') : '')
export const useInstallerAssignedIds = (installerId: string, dateString: string) => {
const { data } = useLiveQuery(
q =>
@evanheckert
evanheckert / tanstack-form-react.mdc
Created April 1, 2025 18:53
Example Cursor Project Rule .mdc for implementing @tanstack/react-form
# Rule: Implement @tanstack/react-form
Description: This rule guides the AI on how to implement forms in React using the `@tanstack/react-form` library, following best practices for common use cases. It covers setup, field creation, validation (sync, async, schema-based), state management, array fields, and submission handling.
Applies to: *.tsx
---
## @tanstack/react-form Implementation Guide
import React, { useState } from 'react';
import {
View,
Text,
TextInput,
TouchableHighlight,
Keyboard,
Modal,
ActionSheetIOS,
Animated,