Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
useToggle
✓ import { useToggle } from 'inspreact'
✗ import useToggle from 'inspreact'
Named export, not default. Use destructured import.
useLocalStorage
✓ import { useLocalStorage } from 'inspreact'
✗ const { useLocalStorage } = require('inspreact')
ESM-only; CommonJS require may not work in all bundlers.
deepClone
✓ import { deepClone } from 'inspreact'
✗ import * as inspreact from 'inspreact'; inspreact.deepClone()
Direct named import preferred; namespace import works but is verbose.
Demonstrates useCounter, useDebounce, useCopyToClipboard, and isEmpty helper.
import { useCounter, useDebounce, useCopyToClipboard, isEmpty } from 'inspreact';
import React from 'react';
function QuickStart() {
const { count, increment, reset } = useCounter(0);
const debouncedCount = useDebounce(count, 500);
const [copied, copy] = useCopyToClipboard();
return (
<div>
<p>Count: {count} (debounced: {debouncedCount})</p>
<button onClick={increment}>Increment</button>
<button onClick={reset}>Reset</button>
<button onClick={() => copy('Hello')}>
{copied ? 'Copied!' : 'Copy'}
</button>
<p>Is empty? {String(isEmpty([]))}</p>
</div>
);
}
Debug
Known issues
gotchauseTheme persists theme in localStorage and updates document.body.dataset.theme; custom theme values must be handled in CSS.fixEnsure CSS rules match dataset.theme values (e.g., [data-theme='dark']).
affects: >=1.0.0
gotchauseLocalStorage throws silently in environments without localStorage (e.g., SSR) if not guarded.fixWrap usage in a check: typeof window !== 'undefined' or use a try-catch.
affects: >=1.0.0
gotchauseClickOutside does not clean up event listeners if ref changes frequently; may cause memory leaks.fixStabilize ref with useRef or useCallback.
affects: >=1.0.0
deprecatedNo deprecation notices as of v1.2.2.
gotchadeepClone does not handle circular references; may cause stack overflow.fixUse a library like lodash cloneDeep for circular objects.
affects: >=1.0.0
Errors
Common errors & fixes
Module ""inspreact"" has no exported member 'useToggle'.
Wrong import syntax or named export misspelling.
fixUse import { useToggle } from 'inspreact' (case-sensitive). Cannot read properties of undefined (reading 'useLocalStorage')
Using CommonJS require or improper import.
fixSwitch to ESM import: import { useLocalStorage } from 'inspreact'. useDebounce is not returning debounced value
Missed that useDebounce returns debounced value, not a function.
fixUse const debouncedValue = useDebounce(value, delay); not useDebounce(callback, delay).
Audit
Dependencies
No dependency data recorded yet.