Migrated from clockwork-dog/cogs-client-lib#90
Edit 19/06/2026
Further detail
This issue refers to the fact that if you grab state from the CogsConnection object via the state getter, then this will give you undefined (state will be {}) for any state value. In reality, client-writable state tends to be initialised to sensible default values anyway, but cogs-writable state will remain undefined until the first sync COGS.
The first sync happens immediately, but this short window does add overhead for custom content authors, as you have to understand that state from the COGS connection (or e.g. when using the useCogsStateValue React hook can be undefined for the first render pass. The types don't actually tell you this, so you could easily make an assumption in code that the value can't be undefined.
Suggested fix is to populate the entire state object on the CogsConnection when it is first initialised with default values from the manifest.
Migrated from clockwork-dog/cogs-client-lib#90
Edit 19/06/2026
Further detail
This issue refers to the fact that if you grab state from the
CogsConnectionobject via thestategetter, then this will give you undefined (statewill be{}) for any state value. In reality, client-writable state tends to be initialised to sensible default values anyway, but cogs-writable state will remain undefined until the first sync COGS.The first sync happens immediately, but this short window does add overhead for custom content authors, as you have to understand that state from the COGS connection (or e.g. when using the
useCogsStateValue React hookcan be undefined for the first render pass. The types don't actually tell you this, so you could easily make an assumption in code that the value can't beundefined.Suggested fix is to populate the entire
stateobject on theCogsConnectionwhen it is first initialised with default values from the manifest.