Skip to main content
rule CX Codex

scroll-position-no-state — Claude Code rule: purpose and setup

scroll-position-no-state is a Claude Code rule that forbids keeping scroll position in useState. It applies to React Native scroll handlers.

AGPL-3.0 ★ 88 updated 2026-11-17

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/scroll-position-no-state.md
Open on GitHub

What scroll-position-no-state does

The rule directs agents away from updating scroll position through useState: scroll events arrive frequently, and repeated state changes trigger renders that can drop frames. For animation, it points to useSharedValue and useAnimatedScrollHandler from react-native-reanimated; for tracking that should not drive rendering, it uses useRef.

Writing to a ref or shared value avoids a React render for each scroll event. To add the rule to Claude Code, place .claude/rules/scroll-position-no-state.md in the project.

What it helps with

  • stop repeated renders during scrolling
  • track scroll position for an animation
  • read scroll position without changing React state

Example prompts for the agent

  • Rewrite the Feed scroll handler so each event does not update useState.
  • Add a scroll-driven animation using the approach from this rule.
  • Review the ScrollView component and replace state-based scroll tracking with useRef.

How to install scroll-position-no-state

Manually: put the files in place

.claude/rules/scroll-position-no-state.md

The paths frontmatter field limits the files

Step by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use

Questions about scroll-position-no-state

How do I install scroll-position-no-state in Claude Code?

Add .claude/rules/scroll-position-no-state.md to the project.

What does scroll-position-no-state do?

It prohibits storing scroll position in useState. For animations it points to a shared value from react-native-reanimated; for tracking that should not trigger rendering, it uses useRef.

What should replace useState for scroll position?

Use useSharedValue with useAnimatedScrollHandler for animation. Use useRef when the value is only tracked and should not trigger a render.

Similar IDE rules

All IDE rules for Mobile →

From the same set47

The whole set →
list-performance-virtualize list-performance-virtualize is a Claude Code rule that recommends virtualized lists for scrollable content. It applies while building list-based screens. CX Codex +1 ★ 88repo stars react-state-minimize react-state-minimize is a Claude Code rule that enforces minimal React state. It directs assistants to compute values on render rather than storing redundant state variables. CX Codex +1 ★ 88repo stars rendering-no-falsy-and rendering-no-falsy-and is a Claude Code rule that guards against unsafe conditional JSX rendering. It targets cases where a value may be an empty string or zero. CX Codex +1 ★ 88repo stars ui-native-modals ui-native-modals is a Claude Code rule that directs coding assistants to use native React Native modal elements instead of JavaScript-based bottom sheet packages. CX Codex +1 ★ 88repo stars impeccable-audit impeccable-audit is a Claude Code skill that reviews Mikka interfaces for UX resilience and visual clarity. It audits screens, responsive behavior, accessibility and interface states. CX Codex +1 ★ 88repo stars web-design-guidelines web-design-guidelines is a Claude Code skill that audits Mikka's web interface for accessibility, responsive layouts, forms, and interaction flows. CX Codex +1 ★ 88repo stars loop-me loop-me is a Claude Code skill that interviews you about a workflow and turns the answers into a specification. With no workflow to start from, it looks for recurring patterns in your workspace. CX Codex +1 ★ 88repo stars mikka-browser-qa mikka-browser-qa is a Claude Code skill that tests Mikka user journeys in a browser. It verifies accessibility trees, touch and keyboard interactions, and checks backend database writes. CX Codex +1 ★ 88repo stars

Project sponsors

Companies that keep this analytics open