4.0.0
Support for Concurrent Rendering
This version adds compatibility for React 18's concurrent rendering by using the useSyncExternalStore hook.
Deprecated option: virtualBatch
Previously, Relink implements its own hook to subscribe to sources, watch for state changes, then decide if a component should update; but with useSyncExternalStore, Relink no longer has control over when to trigger component updates.
On the flipside, even though there is no 1:1 substitution, concurrent rendering might just be able to solve the problem virtualBatch has been trying to solve since day one — to make it possible to defer component updates for complicated states.
In fact, concurrent rendering provides a more granular control: in a sense that you can now tell React which "set state" calls are urgent and which ones are not, instead of only distinguishing them by sources.
Note: Basic selectors do not need to be memoized
// ✅ OK
function SomeComponent(): JSX.Element {
const someState = useRelinkValue(SomeSource, (state) => state.foo)
return /* ... */
}// ✅ Also OK
// Ideal for sharing with components in other files in a consistently manner.
export const someSelector = (state) => state.foo
function SomeComponent(): JSX.Element {
const someState = useRelinkValue(SomeSource, someSelector)
return /* ... */
}// ❌ Unnecessary
function SomeComponent(): JSX.Element {
const selector = useCallback((state) => state.foo, [])
const someState = useRelinkValue(SomeSource, selector)
return /* ... */
}Removal of deprecated APIs
These APIs are marked as deprecated in the previous version and is no longer included in this version.
- (deprecated -> new)
createSource->new RelinkSource(...)isRelinkSource->value instanceof RelinkSource
New exposed constants
(Probably rarely used)
BUILD_HASHBUILD_TYPERelinkBuildType