valdi-tsx

Enforces correct Valdi TSX component patterns and prevents React API misuse.

16.4k|541|Updated Nov 6, 2025
One-click install
npx skills add https://github.com/Snapchat/Valdi --skill valdi-tsx
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: valdi-tsx
Source: https://github.com/Snapchat/Valdi/tree/main/ai-skills/skills/valdi-tsx
Command: npx skills add https://github.com/Snapchat/Valdi --skill valdi-tsx

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

AI assistants frequently hallucinate React patterns—hooks, functional components, this.props, useEffect—that do not exist in Valdi, even though Valdi uses TSX/JSX syntax. This Skill supplies the correct Valdi component, styling, event, and lifecycle rules so generated code compiles to native views on iOS, Android, and macOS.

Core Features & Use Cases

  • React-to-Valdi correction table: Maps useState/useEffect/props to StatefulComponent, setState, viewModel, and onCreate/onViewModelUpdate/onDestroy lifecycles.
  • Styling and layout rules: Documents type-safe Style<View>/Style<Label> usage, Yoga flexbox (flexGrow not flex, gap support), font strings instead of fontSize, and ScrollView restrictions.
  • Platform and API guidance: Covers Device.isIOS/isAndroid/isDesktop guards, provider dependency injection, setTimeoutDisposable timers, @ExportModel ViewModel type restrictions, and new elements like <glass> and <textanimationgroup>.
  • Use Case: When asked to build a Valdi settings screen, the assistant produces a StatefulComponent with onRender() as a void method, element callbacks like onTap, and Style objects—instead of invalid React hooks.

Quick Start

Write a Valdi TSX component with a counter button using StatefulComponent, setState, and correct Valdi styling rules.

Frequently Asked Questions about valdi-tsx

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a Valdi component in TypeScript?

Extend Component or StatefulComponent from valdi_core/src/Component and implement onRender() as a void method where JSX is a statement, not a return value. Use this.viewModel for props and this.setState() to trigger re-renders.

Can I use React hooks like useState in Valdi?

No, React hooks do not exist in Valdi despite the TSX syntax. Use a state property initializer plus this.setState() for updates, and lifecycle methods onCreate, onViewModelUpdate, and onDestroy instead of useEffect.

Does Valdi support flexbox and CSS-style styling?

Valdi uses Yoga flexbox with type-safe Style objects, supporting flexDirection, justifyContent, flexGrow, and gap. It does not support CSS Grid, the flex shorthand, paddingHorizontal, or fontSize—labels use font strings like 'system 20'.

Why does my Valdi code fail when using addEventListener or setInterval?

Valdi has no DOM, so global listeners like addEventListener do not exist; use element callbacks such as onTap, onPress, and onChange. For timers, use this.setTimeoutDisposable() so timers auto-cancel when the component is destroyed.

What types are allowed in Valdi @ExportModel ViewModels?

Only primitive types (string, number, boolean) and other @ExportModel-annotated interfaces can be exported to native code. Custom type aliases like union string literals cause compiler errors and must be kept in internal State instead.