This repository was archived by the owner on Jun 3, 2024. It is now read-only.
4.1.0
Bug fixes
- Fixed issue where child dependencies with source keys of type
symbolwere not checked against when calling.cleanup()on the parent source, resulting in a false negative where no warnings are displayed.
API Changes
keyanddefaultare now exposed as read-only properties of theRelinkSourceclass. This way, it is no longer needed to go through the additional trouble of importing/exporting them when needed because they are already accessible through the source instance.- Deprecated
.cleanup()in favor of.dispose(). - By default,
.dispose()will wait for all queued actions to complete before actually disposing a source. There is aforceoption that can bypass that, but it is strictly intended for being used in teardown functions in tests only. - For hydration,
skipis deprecated and replaced bycommitDefault. There is also a new hydration strategy calledcommitNoopto complete the hydration without triggering any state changes. useRelinkValue(...)now accepts a third argument to control whether the hook should listen for state changes
// Without selector
useRelinkValue(Source, null, true /* or false */ )
// With selector
useRelinkValue(Source, selector, true /* or false */ )Miscellaneous
- Improved documentation in the TypeScript definition file as well as runtime messages for debugging (development env only) for more clarity.
- Compilation target of this package has been set to ES2020.
Known Issues
- In the examples of
.cleanup()and.dispose()in the.d.tsfile, creating sources in the render phase then disposing them in cleanup effects inStrictModewill cause an error. Indeed, eventually, the source is created and disposed twice, just as inteneded by Strict Mode, but the order in which they are created and disposed seems to be jumbled up.- Demonstration:
- Clone the repository, run
yarn install, then runyarn playground:web - Navigate to http://localhost:3000/dynamic-create-dispose
- During initial render, everything seems fine
- Click on "Increase counter", a TypeError will be thrown.
- Clone the repository, run
- Intended behaviour:
- 1st render phase: Source is created
- 1st Cleanup phase: Source is disposed
- 2nd render phase: Source is created
- Actual behaviour:
- 1st render phase: Source is created
- 2nd render phase: Source is created
- 1st Cleanup phase: Source is disposed
- Demonstration: