Skip to content

v6.23.1

Choose a tag to compare

@alex-up-bot alex-up-bot released this 19 May 01:34
· 117 commits to main since this release

v6.23.1 (Patch Release)

Status: Released

This is a new patch release of the @alextheman/components package. It includes small, non-breaking changes and should require no refactoring. Please read the description of changes below.

Description of Changes

  • Fix nullComponent in QueryBoundary.Nullable not being recognised.
    • When using our new compound QueryBoundary pattern, we take either the data or dataCollection to allow for either any data type or an array of data items. The distinction matters because we have QueryBoundaryData which purely just resolves query data, and QueryBoundaryDataMap which assumes the data is an array and maps over it.
    • When passing these into the QueryBoundaryProvider for initialisation, the initial logic used nullish coalescing to determine which one to use. This was problematic because if data was null, the nullish coalescing would fall back to dataCollection instead of preserving the original null value.
    • However, in the QueryBoundary system, null and undefined are intentionally treated as distinct states and therefore need to be preserved correctly. As such, the approach has been changed to check if the data key is present in the query, and if so use that, otherwise use the dataCollection.
    • This preserves null for both data and dataCollection, therefore allowing nullComponent to work.

Additional Notes

  • It took me some time to figure that one out, I'll admit.
  • Because the QueryBoundary system now coordinates several related components together, it can be difficult sometimes to narrow down exactly where the error is happening.
  • Not to mention, in Lexicon I'm extending the QueryBoundary with some extra behaviour too, so the first thought was potentially something Lexicon-specific (e.g. the API may be somehow returning undefined for the currentUser).
  • That said, I eventually narrowed it down when I tried using QueryBoundary.Nullable in Lexicon directly and got a similar result. That was a giveaway because Lexicon doesn't wrap that component. That feeling was further justified when I created the Null story in components to verify, and that story test did fail.
  • So... big win for Storybook testing again, am I right?