How can I log G
from a move? It logs a Proxy I can’t inspect.
#1029
-
I have a NotesI'm using it with Vue.js console.log(G) screenshotmoves: {
put_on_board: ( G, ctx, card ) => {
console.log( G )
console.log( ctx )
console.log( card )
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi! This is because Basically, say you do You have a couple of options:
|
Beta Was this translation helpful? Give feedback.
-
you could also just store G as json and then parse as json to get back the actual object ie: |
Beta Was this translation helpful? Give feedback.
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 thescore
property directly on that object. Any other code that perhaps was trying to keep track of an olderG
state for example, would be liable to also get updated because both are holding a reference to a singleG
object. We use Immer to avoid this.You have a couple of options:
Log out a part of
G
that is not an Object, e.g.console