fp-react

Implements fp-ts patterns for React state, forms, and data fetching.

1|Updated Aug 17, 2025
One-click install
npx skills add https://github.com/ratnesh-maurya/mdconverter --skill fp-react-ratnesh-maurya
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fp-react
Source: https://github.com/ratnesh-maurya/mdconverter/tree/main/.claude/skills/fp-react
Command: npx skills add https://github.com/ratnesh-maurya/mdconverter --skill fp-react-ratnesh-maurya

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires fp-ts, fp-ts-react-stable-hooks, @devexperts/remote-data-ts, io-ts, zod.

What problem does it solve? React codebases often rely on null checks, boolean loading flags, and ad-hoc error handling that allow impossible states and runtime bugs. This Skill provides concrete fp-ts patterns (Option, Either, TaskEither, RemoteData) that make state explicit and type-safe in React and Next.js applications. ## Core Features & Use Cases - State Modeling: Replace null/undefined with Option and replace loading/error booleans with a four-state RemoteData type that eliminates impossible UI states. - Form Validation: Use Either with applicative validation to collect all field errors at once, including field-level error maps for better UX. - Data Fetching: Wrap fetch calls in TaskEither, chain or parallelize API calls, and integrate with React 19 features like use(), useActionState, and useOptimistic. - Use Case: When building a signup form in a Next.js 15 app, use the provided Either-based validation to show all errors at once, then submit through useActionState with pending state handling. ## Quick Start Show me how to fetch a user from an API in my React component using TaskEither and render loading, error, and success states with RemoteData.

Frequently Asked Questions about fp-react

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

FAQPage Schema
How do I use fp-ts Option in React state?

Store Option values with useState and render with O.match to handle the some and none cases. Memoize Option creation with useMemo or depend on the raw value in effects, since O.some creates a new object each render.

How to validate forms with fp-ts Either in React?

Write validators returning Either<string, string>, then combine them with sequenceS and getApplicativeValidation to collect all errors at once. Use E.match in the submit handler to display errors or submit valid data.

What is the RemoteData pattern for React data fetching?

RemoteData is a four-state union type: NotAsked, Loading, Failure, and Success. It replaces separate data, loading, and error booleans, making impossible states unrepresentable and forcing the UI to handle every case explicitly.

Does fp-ts work with React 19 and Next.js 15?

Yes, fp-ts works with React 18/19 and Next.js 14/15. The patterns integrate with React 19 features like use() for promises, useActionState for form actions, and useOptimistic for instant UI feedback.

Why do fp-ts values cause extra re-renders in React?

Constructors like O.some create new object references each render, so React treats them as changed in dependency arrays. Fix this with useMemo around Option creation or use fp-ts-react-stable-hooks with fp-ts equality functions.

When should I use TaskEither instead of plain fetch in React?

Use TaskEither when async operations can fail and you want typed, composable error handling. It lets you chain dependent calls with flatMap, run parallel requests with sequenceT, and match on success or failure without try/catch blocks.