Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

4.1.0

Choose a tag to compare

@glyph-cat glyph-cat released this 16 Oct 16:11

Bug fixes

  • Fixed issue where child dependencies with source keys of type symbol were not checked against when calling .cleanup() on the parent source, resulting in a false negative where no warnings are displayed.

API Changes

  • key and default are now exposed as read-only properties of the RelinkSource class. 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 a force option that can bypass that, but it is strictly intended for being used in teardown functions in tests only.
  • For hydration, skip is deprecated and replaced by commitDefault. There is also a new hydration strategy called commitNoop to 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.ts file, creating sources in the render phase then disposing them in cleanup effects in StrictMode will 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 run yarn 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.
    • 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