padroes-react-typescript

Defines React and TypeScript coding conventions for components, hooks, services, and typing.

Updated Jan 28, 2024
One-click install
npx skills add https://github.com/Thiago-Cruz-eng/KrockSide --skill padroes-react-typescript-thiago-cruz-eng
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: padroes-react-typescript
Source: https://github.com/Thiago-Cruz-eng/KrockSide/tree/main/.agents/skills/padroes-react-typescript
Command: npx skills add https://github.com/Thiago-Cruz-eng/KrockSide --skill padroes-react-typescript-thiago-cruz-eng

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? It keeps a React + TypeScript codebase consistent by documenting the enforced layer flow (components → hooks → service → types), naming rules, strict typing policies, and CSS conventions, so new code and reviews follow the same standard. ## Core Features & Use Cases - Layered architecture rules: Components never import axios or SignalR directly; only src/service/Api.ts touches credential storage. - Component and hook conventions: React.FC with exported props interfaces, hooks returning named-object APIs with useCallback, and one component per file. - Strict typing policy: No any, @ts-ignore, or unchecked casts; hub payload casts happen once at the boundary, and errors are narrowed from unknown. - Use Case: When creating a new component, hook, or service in the KrockSide frontend, consult this Skill to match the project's folder structure, naming, typing, and styling rules before opening a pull request. ## Quick Start Ask the AI to create a new React component or custom hook following the project's React and TypeScript conventions.

Frequently Asked Questions about padroes-react-typescript

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

FAQPage Schema
How do I structure a React component in TypeScript?

Use React.FC with an exported props interface, one component per file named in PascalCase, and default export at the end. Import its CSS from a styles folder at the top, and use early returns for loading and error states.

How should a custom React hook return its API?

Return a named object, never a tuple, with an exported interface describing the API. Wrap every returned function in useCallback with correct dependencies so consumers can safely use them in useEffect dependency arrays.

Can React components call axios or SignalR directly?

No. Components must go through the service layer for REST calls or through hooks like useHubConnection for hub events. Importing axios or @microsoft/signalr inside a component is treated as an architecture violation.

How do I type SignalR hub event payloads in TypeScript?

Cast the payload once at the boundary inside the event handler, using an explicit event interface from the types folder. Always pass explicit generic types to invoke and post calls, and narrow caught errors from unknown before use.

When should I avoid useEffect dependency loops with SignalR?

A connection factory passed inline recreates the connection on every render because it is a new reference each time. Memoize the factory with useCallback so the provider's useEffect dependencies stay stable.