@zenreact/core
TypeScript icon, indicating that this package has built-in type declarations

0.1.6 • Public • Published

@zenreact/core

Core optimization features for ZenReact - High-performance React state management and rendering optimization

npm version bundle size npm downloads

Installation

pnpm add @zenreact/core

Peer Dependencies

  • React 17.0.0+ or 18.0.0+
  • ReactDOM 17.0.0+ or 18.0.0+

API

withOptimization

Higher-order component (HOC) that automatically optimizes React component rendering:

import { withOptimization } from '@zenreact/core';

function MyComponent({ data }) {
  return (
    <div>
      <h1>{data.title}</h1>
      <p>{data.content}</p>
    </div>
  );
}

export default withOptimization(MyComponent);

The HOC:

  • Prevents unnecessary re-renders
  • Implements smart prop comparison
  • Maintains component display name for debugging
  • Zero configuration required

useOptimizedState

Hook that provides optimized state management:

import { useOptimizedState } from '@zenreact/core';

function SearchBox() {
  const [search, setSearch] = useOptimizedState("");

  return (
    <input 
      value={search} 
      onChange={(e) => setSearch(e.target.value)} 
    />
  );
}

Features:

  • Automatic debouncing of rapid updates
  • Smart value comparison
  • Memory efficient
  • Type-safe (TypeScript support)

Package Details

  • Side Effects: None (sideEffects: false)
  • Module Formats:
    • CommonJS: dist/index.js
    • ESM: dist/index.esm.js
    • TypeScript types: dist/index.d.ts
  • Bundle Size: < 3KB minified + gzipped
  • Browser Support: All modern browsers, IE11 with polyfills

Development

Build

pnpm build

Builds the package using TypeScript and Rollup.

Test

# Run tests
pnpm test

# Watch mode
pnpm test:watch

# Coverage report
pnpm test:coverage

Uses Jest with React Testing Library.

Type Check

pnpm typecheck

Runs TypeScript type checking without emission.

Contributing

Please see the Contributing Guide.

Documentation

License

MIT © Zen Development Team

Package Sidebar

Install

npm i @zenreact/core

Homepage

zenreact.dev

Weekly Downloads

6

Version

0.1.6

License

MIT

Unpacked Size

27.9 kB

Total Files

35

Last publish

Collaborators

  • lamtran2601