Releases: vothanhdat/react-state-custom
[1.0.33] - 2026-02-22
What's Changed
- Added
StateScopeProvidercomponent for isolated nested state — allows subtrees to mount their own independent store instance, preventing state leakage between siblings or nested consumers. - Re-exported
StateScopeProviderfrom the package entrypoint (src/index.ts). - Rewrote README and API documentation for clarity and impact; fixed example imports and corrected
AutoRootCtxusage docs. - Added
AI_CONTEXT.mdwith guidelines on preferred patterns and API usage for AI-assisted development.
Full Changelog: v1.0.32...v1.0.33
# Release Node v1.0.32
🚀 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 newcreateStoreanduseStoreAPIs. - Tests: Added comprehensive test coverage for
createStoreand verified synchronous subscription behavior.
Release Notes - v1.0.31
🚀 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 IDsParamsToIdRecord- 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
ParamsToIdRecordtype documentation - Added usage examples for
AttatchedComponentfeature - Updated tests README with accurate test counts (76 tests passing)
🧪 Tests
- Added 3 new tests for
AttatchedComponentfeature:- 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-viewdependency to v1.1.1 - Enhanced StackBlitz editor configuration (hidden explorer, adjusted terminal height)
Full Changelog: v1.0.29 → v1.0.31
v1.0.28
Full Changelog: v1.0.27...v1.0.28
v1.0.27
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
Full Changelog: 1.0.24...v1.0.25
v1.0.24
Full Changelog: v1.0.19...1.0.24
v1.0.19
Update document
v1.0.15
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