atomico-hooks-core

Provide core Atomico hooks for state, memoization, refs, and updates.

1.3k|44|Updated Aug 25, 2018
One-click install
npx skills add https://github.com/atomicojs/atomico --skill atomico-hooks-core
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: atomico-hooks-core
Source: https://github.com/atomicojs/atomico/tree/main/.agents/skills/atomico-hooks-core
Command: npx skills add https://github.com/atomicojs/atomico --skill atomico-hooks-core

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides concise, predictable primitives to manage local reactive state, memoized computations, persistent references, host element access, forced updates, stable IDs, and low-level hook composition inside Atomico web components, avoiding ad-hoc state and DOM handling and differentiating from React hook semantics.

Core Features & Use Cases

  • Local state management with useState for reactive component values and strict equality setter behavior.
  • Performance primitives including useMemo and useCallback for caching expensive computations and stable function references.
  • DOM and lifecycle utilities such as useRef for element refs, useHost for accessing the custom element, useUpdate to force re-renders, useId for stable identifiers, and useHook to build custom hooks.
  • Use Case: Implement an accessible form component that uses useId for labels, useRef to focus inputs, useState for controlled values, and useMemo to compute validation results efficiently.

Quick Start

Import the Atomico hooks into your component and replace ad-hoc state and DOM logic with useState, useRef, useHost, useMemo, and useHook as needed.

Frequently Asked Questions about atomico-hooks-core

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

FAQPage Schema
How do I manage local state in Atomico web components?

Manage local state in Atomico web components using the useState hook for reactive values with strict equality setter behavior. It provides predictable primitives to handle component state without ad-hoc logic, differentiating from React hook semantics.

What's the best way to memoize expensive computations in Atomico?

Memoize expensive computations in Atomico using the useMemo hook for caching calculated values and useCallback for stable function references. These performance primitives rely on dependency-driven memoization to avoid unnecessary recalculations during component re-renders.

How do I access DOM elements and the host custom element in Atomico?

Access DOM elements and the host custom element in Atomico using useRef for persistent typed references to elements and useHost to retrieve the custom element itself. These utilities streamline DOM and lifecycle handling inside web components.

Does Atomico provide a hook for generating stable IDs for accessible forms?

Atomico provides the useId hook specifically for generating stable identifiers, which is essential for creating accessible form components. It ensures consistent label-input associations across re-renders without relying on manual ID generation.

Can I force a re-render or build custom hooks in Atomico web components?

Force re-renders in Atomico using the useUpdate hook, and build custom hooks using the useHook low-level primitive. These tools allow strict control over component update lifecycles and enable composition of custom hook logic.

Do I need Atomico version 1.79 or higher to use these core hooks?

These core hooks require Atomico version 1.79 or higher to ensure compatibility with stable hook lifecycles and strict equality setter behavior. Verify your project's Atomico dependency meets this minimum version requirement before implementation.