Skip to content

Is there a way to preserve class component state between code refreshes? #264

@davidyang

Description

@davidyang

I'm using shadow-cljs and re-rendering on file save. Is there a way to preserve component state between renders?

I've tried a few things without luck:

  • Writing a mixin that stores any atoms in state. The problem is that it's hard to get a unique key for a component that persists between renders
  • Wrapping the render with a functional component that contains a ref. I think React maintains this ref if fast-refresh is enabled, but that doesn't seem to work here.

Any other ideas on generating an id or signature that is unique to a component's position in the render tree would be appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions