8-bit-pixel-art-patter…
Create pixelated borders, shadows, and effects for 8-bit retro components. Apply when…
Hoist RegExp creation outside render or memoize with useMemo(). Apply when using regular expressions in React components or frequently called functions.
$ npx -y skills add theorcdev/8bitcn-ui --skill js-hoist-regexp --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/js-hoist-regexpContext preview
The summary Claude sees to decide when to auto-load this skill.
Hoist RegExp creation outside render or memoize with useMemo(). Apply when using regular expressions in React components or frequently called functions.
name: js-hoist-regexp description: Hoist RegExp creation outside render or memoize with useMemo(). Apply when using regular expressions in React components or frequently called functions.
Don't create RegExp inside render. Hoist to module scope or memoize with `useMemo()`.
**Incorrect (new RegExp every render):**
function Highlighter({ text, query }: Props) {
const regex = new RegExp(`(${query})`, 'gi')
const parts = text.split(regex)
return <>{parts.map((part, i) => ...)}</>
}**Correct (memoize or hoist):**
const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
function Highlighter({ text, query }: Props) {
const regex = useMemo(
() => new RegExp(`(${escapeRegex(query)})`, 'gi'),
[query]
)
const parts = text.split(regex)
return <>{parts.map((part, i) => ...)}</>
}**Warning (global regex has mutable state):**
Global regex (`/g`) has mutable `lastIndex` state:
const regex = /foo/g
regex.test('foo') // true, lastIndex = 3
regex.test('foo') // false, lastIndex = 0Accessible retro components that you can copy and paste into your apps.Free. Open Source. Built on shadcn/ui. Documentation · Components · Blocks · Themes · Discord
Repo: theorcdev/8bitcn-ui
Create pixelated borders, shadows, and effects for 8-bit retro components. Apply when…
Create documentation with gaming-specific examples, retro styling, and 8-bit terminology.…
Optimize 8-bit animations for smooth performance. Apply when creating animated pixel art,…
Import directly from source files instead of barrel files. Apply when using libraries like…
Use next/dynamic for lazy-loading heavy components. Apply when importing large components…
Best practices for wrapping shadcn/ui components. Apply when creating 8-bit styled variants…