Skip to content

State should default to manifest value to avoid ever being undefined #12

Description

@chetbox

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions