Releases: Harvtronix/react-substate
v6.0.3
Fix eslint hooks rule naming collision
Full Changelog: v6.0.2...v6.0.3
v6.0.2
Fix packaging issue
Full Changelog: v6.0.1...v6.0.2
v6.0.1
Fixes a packaging issue
Full Changelog: v6.0.0...v6.0.1
v6.0.0
This release has breaking changes!
Migrating from 5.x to 6.x
The 6.0 release includes breaking changes to what useSubstate
returns, as well as the removal of the Immer "patch" support that was previously exposed via usePatchEffect
. The globalDispatch
function has also been renamed to just dispatch
.
useSubstate
Where you previously had something like:
const [test, dispatch] = useSubstate(substates.test)
Or as was often the case in larger applications:
const [test, dispatchTest] = useSubstate(substates.test)
You will instead use the clearer and less error-prone syntax of:
const test = useSubstate(substates.test)
To get the current value of a substate, use:
test.current
And to get the Substate-specific dispatch function, use:
test.dispatch(...)
If you really want to still destructure these into {current: test, dispatch}
you can, however this is not the recommended approach.
useGlobalDispatch
Where you previously had something like:
const globalDispatch = useGlobalDispatch()
You will instead use:
const dispatch = useDispatch()
usePatchEffect
This hook has been removed and there is no planned replacement for it. If you still need its functionality, use v5.x instead.
TypeScript enhancements
The typing of React Substate is now better ar preventing users from doing the "wrong thing" by carrying forward types from Substate definitions all the way through to Actions verbatim and no longer widening types when additional properties are provided to either drafts or payloads.
Full Changelog: v5.3.3...v6.0.0
v5.3.3
Full Changelog: v5.3.2...v5.3.3
v5.3.2
Full Changelog: v5.3.1...v5.3.2
v5.3.1
Summary
Lazy loads substates supplied as a generator function. Loading now happens the first time the substate is used.
Full Changelog: v5.3.0...5.3.1
v5.3.0
Assorted quality of life features.
Summary
- Update deps minor versions
- Allow substates to be initialized via generator function
- Add useGlobalDispatch
- Improve redux dev tools integration
Full Changelog: v5.2.0...v5.3.0
v5.2.0
Improved compatibility of types and a couple extra logic guards.
Summary
- Fix broken types in some environments
- Improve separation between mjs and cjs build output
- Use
tsc
for all builds instead of rollup - Add additional checks for whether or not a substate exists. This will cause some error paths to begin throwing errors, which is new behavior, but react-substate literally wouldn't have provided any value down these paths anyway, so I'm not marking it as a breaking change.
Full Changelog: v5.1.1...v5.2.0
v5.1.1
Just some bug fixes
Summary
- Update the README and provide a TypeScript example
- Fix some broken types relating to initial substate shape
- Fix some broken types relating to valid return values from action state modifier functions
- Update some debug mode statements