v6.23.1
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
nullComponentinQueryBoundary.Nullablenot being recognised.- When using our new compound
QueryBoundarypattern, we take either thedataordataCollectionto allow for either any data type or an array of data items. The distinction matters because we haveQueryBoundaryDatawhich purely just resolves query data, andQueryBoundaryDataMapwhich assumes the data is an array and maps over it. - When passing these into the
QueryBoundaryProviderfor initialisation, the initial logic used nullish coalescing to determine which one to use. This was problematic because ifdatawasnull, the nullish coalescing would fall back todataCollectioninstead of preserving the originalnullvalue. - However, in the
QueryBoundarysystem,nullandundefinedare intentionally treated as distinct states and therefore need to be preserved correctly. As such, the approach has been changed to check if thedatakey is present in the query, and if so use that, otherwise use thedataCollection. - This preserves
nullfor bothdataanddataCollection, therefore allowing nullComponent to work.
- When using our new compound
Additional Notes
- It took me some time to figure that one out, I'll admit.
- Because the
QueryBoundarysystem 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
QueryBoundarywith 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.Nullablein 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?