qzx-reactive
v3.0.3
Published
A reactive component library with lifecycle management and state tracking.
Readme
qzx-reactive
A reactive component library with lifecycle management and state tracking.
Features
- Reactive component wrapper (RComponent)
- Lifecycle hooks (useMounted, useBeforeUnmount)
- State management (useReactive, useComputed)
- Automatic dependency tracking
- Efficient caching mechanism
Installation
npm install qzx-reactiveUsage
import { RComponent, useReactive } from 'qzx-reactive';
const Counter = RComponent(() => {
const state = useReactive({ count: 0 });
return (
<div>
<p>Count: {state.count}</p>
<button onClick={() => state.count++}>Increment</button>
</div>
);
});API
RComponent(Component)
Wraps a functional component with reactive capabilities.
Hooks
- useReactive(initialState) - Creates reactive state object
- useComputed(fn) - Creates computed value
- useMounted(fn) - Runs callback on component mount
- useBeforeUnmount(fn) - Runs callback before unmount
Testing
Run tests with:
npm testLicense
MIT
