Skip to content

Releases: vothanhdat/react-state-custom

[1.0.33] - 2026-02-22

22 Feb 06:11
aeb078d

Choose a tag to compare

What's Changed

  • Added StateScopeProvider component for isolated nested state — allows subtrees to mount their own independent store instance, preventing state leakage between siblings or nested consumers.
  • Re-exported StateScopeProvider from the package entrypoint (src/index.ts).
  • Rewrote README and API documentation for clarity and impact; fixed example imports and corrected AutoRootCtx usage docs.
  • Added AI_CONTEXT.md with guidelines on preferred patterns and API usage for AI-assisted development.

Full Changelog: v1.0.32...v1.0.33

# Release Node v1.0.32

30 Nov 15:26

Choose a tag to compare

🚀 New Features

createStore API

We've introduced createStore, a new simplified factory that combines createRootCtx and createAutoCtx into a single step. This reduces boilerplate for the most common use cases.

// Before
const Root = createRootCtx('my-store', useMyHook);
const { Provider, useCtxState } = createAutoCtx(Root);

// Now
const { Provider, useStore } = createStore('my-store', useMyHook);

useStore Hook

Both createStore and createAutoCtx now return a useStore hook. This hook provides direct, proxy-based access to your state without needing to manually pass the context object to useQuickSubscribe.

// In your component
const { count } = useStore(); // Returns the reactive state proxy directly
return <div>{count}</div>;

Warm-Start Support (preState)

Root hooks now receive a second argument: preState. This allows the store to initialize with data preserved from a previous mount, ensuring state continuity when AutoRootCtx remounts the underlying root component.

⚡ Improvements

  • Documentation: Added a new "Composing Stores" section to the README, documenting patterns for derived state and store composition.

🛠 Maintenance

  • Examples: All 5 example projects (counter, todo, form, timer, cart) have been refactored to use the new createStore and useStore APIs.
  • Tests: Added comprehensive test coverage for createStore and verified synchronous subscription behavior.

Release Notes - v1.0.31

25 Nov 10:04

Choose a tag to compare

🚀 New Features

AttatchedComponent Support in createAutoCtx

Added a new optional third parameter AttatchedComponent to createAutoCtx that allows you to render a companion component alongside each auto-mounted root instance.

// A component that logs when a user context is active
const UserLogger: React.FC<{ userId: string }> = ({ userId }) => {
  useEffect(() => {
    console.log(`User ${userId} context mounted`)
    return () => console.log(`User ${userId} context unmounted`)
  }, [userId])
  return null
}

const { useCtxState: useUserCtx } = createAutoCtx(
  createRootCtx("user", useUserState),
  200,           // unmountDelayMs
  UserLogger     // AttatchedComponent - NEW!
)

This is useful for:

  • Side effects that should live alongside the state
  • Rendering portals or overlays per context instance
  • Logging/debugging context lifecycles

New Exports

Added new type exports for better TypeScript support:

  • paramsToId - Utility function for converting params to deterministic IDs
  • ParamsToIdRecord - Type constraint for params (primitives only)
  • ParamsToIdInput - Input type for paramsToId function
import { paramsToId, type ParamsToIdRecord } from 'react-state-custom'

📚 Documentation

  • Enhanced API documentation with ParamsToIdRecord type documentation
  • Added usage examples for AttatchedComponent feature
  • Updated tests README with accurate test counts (76 tests passing)

🧪 Tests

  • Added 3 new tests for AttatchedComponent feature:
    • Renders AttatchedComponent alongside state runner
    • Passes params correctly to AttatchedComponent
    • Renders multiple AttatchedComponents for different params

Total: 76/76 tests passing (100%)

📦 Other Changes

  • Updated react-obj-view dependency to v1.1.1
  • Enhanced StackBlitz editor configuration (hidden explorer, adjusted terminal height)

Full Changelog: v1.0.29 → v1.0.31

v1.0.28

12 Nov 05:05

Choose a tag to compare

Full Changelog: v1.0.27...v1.0.28

v1.0.27

27 Oct 07:55

Choose a tag to compare

What's Changed

  • Fix Yarn PnP ESM incompatibility and test code issues blocking test execution by @Copilot in #15
  • Require Node 20 or above by @Copilot in #18

Full Changelog: v1.0.25...v1.0.27

v1.0.25

23 Oct 13:08

Choose a tag to compare

Full Changelog: 1.0.24...v1.0.25

v1.0.24

23 Oct 01:59

Choose a tag to compare

Full Changelog: v1.0.19...1.0.24

v1.0.19

18 Oct 08:58

Choose a tag to compare

Update document

v1.0.15

11 Aug 05:05

Choose a tag to compare

What's Changed

  • [FEATURE] Complete API documentation for all exported items with comprehensive examples by @Copilot in #9

Full Changelog: https://github.com/vothanhdat/react-state-custom/commits/v1.0.15