Project not loading - Error property 0.

Blocking - I opened up a project today that was working fine the last time I checked and I get an error in preview : Error: Cannot read property 0 - data is still loading . After checking everything I could think of three times over, I am starting to wonder if maybe it’s not on my side.

The errors in console are not very revealing.

image.png

@chungwu I think I tracked down this error to a state variable that has an initial value based on a query. If I remove the initial value, the error goes away.

However, I believe it worked before despite it relying on the query for initial value.

Is there a better way to initialize a state variable in this case so it waits until the query has finished loading?

This is what the state’s initial (dynamic) value is set to right now:

Isn’t the fallback supposed to kick in if/while the query is not available?

After much poking, I was able to isolate the issue to a Data provider that had a Data prop set as in the screenshot. The only workaround I could find is to set the Data Provider component to Not Rendered, since anything else causes the error in Preview - even if the Data Provider is empty/no children.

Can a Data Provider not rely on a state variable for its data?

image.png

I just did a test and if I point the Data Provider directly to the results of the query, not passing through the state variable, everything works.

Could this be related to this commit from 2 days ago? The timing of the errors appearing would make sense in this case: https://github.com/plasmicapp/plasmic/commit/52e590a6d596fb3841488f04b311b79c496e2eb6

Thanks for the report; we’re thinking through the issue!

For now I believe you can also work around this by avoiding referencing loading data, by guarding query data access in your initial state value…

// initial state value
$queries.getTmRow?.isLoading ? undefined : $queries.getTmRow.data[0].content

Good tip on the isLoading! I tried something similar to check if it’s defined first, but I forgot about isLoading. Cool.