Skip to content
Back to skills

Reactive Polling

ASecurity

Poll for changes to any value and trigger React re-renders when it changes.

  • 31 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added May 27, 2026
developmentreactgit

Security analysis

A100/100

Scanned May 27, 2026

npx -y skills add verekia/r3f-gamedev --skill reactive-polling --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Reactive Polling?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Reactive Polling
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/verekia-reactive-polling/badge)](https://www.skillsdirectory.com/skills/verekia-reactive-polling)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: reactive-polling
description: Poll for changes to any value and trigger React re-renders when it changes.
---

# Reactive Polling

Poll for changes to any value and trigger React re-renders when it changes.

## Technique

Create a `useReactive` hook that uses `useFrame` to periodically check a selector function. When the value changes, update React state to trigger a re-render. Throttle with a configurable FPS.

## Key Concepts

- Selector function returns the value to watch
- Compare with previous value to detect changes
- Only update state when value actually changes
- Throttle polling with `useFrame`'s `fps` option
- Use sparingly for values that don't change frequently

## Usage

```tsx
const useReactive = <T,>(selector: () => T, fps = 30): T => {
  const [reactiveValue, setReactiveValue] = useState<T>(selector())
  const previousValueRef = useRef(reactiveValue)

  useFrame(
    () => {
      const newValue = selector()
      if (previousValueRef.current !== newValue) {
        previousValueRef.current = newValue
        setReactiveValue(newValue)
      }
    },
    { fps },
  )

  return reactiveValue
}

// Usage
const isAboveZero = useReactive(() => position.y > 0)
```

---

This skill is part of [verekia](https://x.com/verekia)'s [**r3f-gamedev**](https://github.com/verekia/r3f-gamedev).

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.