Skip to content

feat: add ref support for DOM element access#44

Merged
stefvw93 merged 4 commits intomainfrom
feat/ref
Jan 22, 2026
Merged

feat: add ref support for DOM element access#44
stefvw93 merged 4 commits intomainfrom
feat/ref

Conversation

@stefvw93
Copy link
Owner

@stefvw93 stefvw93 commented Jan 22, 2026

Summary

  • Add support for ref prop on JSX elements using Effect's Ref and SubscriptionRef
  • Refs use Ref<Option<HTMLElement>> pattern for type-safe element access
  • Works with both Ref (imperative access) and SubscriptionRef (reactive mount detection via .changes)
  • Add comprehensive test coverage for ref handling (10 test cases)
  • Add element-ref recipe demonstrating practical patterns: auto-focus, dimension measurement, canvas drawing, scroll-into-view

Test plan

  • All 99 tests pass (pnpm test)
  • TypeScript compiles without errors (pnpm typecheck)
  • Lint passes (pnpm lint)
  • Manual verification: Open playground/recipes/element-ref/ in browser and verify examples work

🤖 Generated with Claude Code

stefvw93 and others added 4 commits January 22, 2026 21:41
Add comprehensive test coverage for ref support and create a practical
recipe demonstrating element ref usage patterns including auto-focus,
dimension measurement, canvas drawing, and scroll-into-view.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use object wrapper for captured element to avoid TypeScript control
flow analysis issues with closure mutations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@stefvw93 stefvw93 merged commit 81a5ec0 into main Jan 22, 2026
6 checks passed
@stefvw93 stefvw93 deleted the feat/ref branch January 22, 2026 20:54
@github-actions
Copy link

🎉 This PR is included in version 0.5.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant