Filtering on component params for child components

Hi!

I am trying to create a “Collection” component in create. The component has a collection object as input, which is required. In the component I am trying to calculate the number of sensors in that collection and pass that along to another component displaying that information within the component. That second component takes in a string.

We have a connection database object called “Sensor - Collection", and I am trying to pass this: ```return `${sensorCollection.length} sensors` ``` into the component. The sensor-collection object is filtered on Collection = Collection (from the parent component param). The entire application crashes and I get this message when trying to load the page: “Cannot read properties of undefined (reading ‘getSingleObject’)”.

Hi martbart, thanks for reaching out! Did you find a solution to this issue yet?

This error could occur when a data source used inside a Shareable Component is filtered on a parameter (of type object class), but the param is undefined or not yet resolved on first render.

A good first step would be to add a guard in the function that checks that sensorCollection is not empty, and do some more debugging to check if the param object is available on render. If its not, you can explore options like switching to a runtime datasource and read it On View Load so you can make sure the data is ready before it renders. If you want to keep it database connected, you could also look at a visibility condition on the component so it only renders when the Collection param has value.

Hope this was helpful!

Tonje