Loading...
Loading...
React 18 patterns for LlamaFarm Designer. Covers components, hooks, TanStack Query, and testing.
npx skill4agent add llama-farm/llamafarm react-skillstailwind-mergeclsxdesigner/src/
api/ # API service functions
components/ # React components (feature-organized)
contexts/ # React context providers
hooks/ # Custom hooks
lib/ # Utility functions (cn, etc.)
types/ # TypeScript type definitions
utils/ # Helper functions
test/ # Test utilities and mocksforwardRefdisplayNameuseStateuseReduceruseQueryuseMutationuseMemouseCallbackcn()lib/utilscvadark:// Utility for merging Tailwind classes
import { cn } from '@/lib/utils'
cn('base-class', condition && 'conditional-class', className)
// Query key factory pattern
export const projectKeys = {
all: ['projects'] as const,
lists: () => [...projectKeys.all, 'list'] as const,
list: (ns: string) => [...projectKeys.lists(), ns] as const,
}
// Context with validation hook
const MyContext = createContext<MyContextType | undefined>(undefined)
export function useMyContext() {
const ctx = useContext(MyContext)
if (!ctx) throw new Error('useMyContext must be within MyProvider')
return ctx
}import { renderWithProviders } from '@/test/utils'
import { screen } from '@testing-library/react'
test('renders component', () => {
renderWithProviders(<MyComponent />)
expect(screen.getByText('Hello')).toBeInTheDocument()
})