Skip to content

How can I log G from a move? It logs a Proxy I can’t inspect. #1029

Answered by delucis
ilse-langnar asked this question in Q&A
Discussion options

You must be logged in to vote

Hi! This is because G gets turned into an Immer “draft” object inside moves to allow for easier updates (there are some details on the “Immutability” doc page), that’s why you see the Proxy, which will usually expire before you can inspect it in the console.

Basically, say you do G.score = 5 in your move. With a standard JavaScript object, that would mutate the score property directly on that object. Any other code that perhaps was trying to keep track of an older G state for example, would be liable to also get updated because both are holding a reference to a single G object. We use Immer to avoid this.

You have a couple of options:

  1. Log out a part of G that is not an Object, e.g.

    console

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by delucis
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1028 on November 01, 2021 22:16.