Skip to content

devtool doesn't show value of getter #733

Answered by dai-shi
lake2 asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for reporting.

Class getters are not own properties, and it's not handled by snapshot(). It's by design.

An easy workaround is to use object getters.

const state_3 = proxy({
  spinning: false,
  get number() {
    return this.spinning ? 1 : 0;
  },
  toggle() {
    this.spinning = !this.spinning;
  },
});

Or maybe coping prototype after instantiating a class...

There might be a devtool specific solution, but that would be fairly complicated and not very maintainable.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@lake2
Comment options

Answer selected by lake2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants