Skip to content

Can my state objects have functions? How about a toJSON function? #785

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

You must be logged in to vote

Yes, but be careful with this. If you are not familiar with this behavior, better to avoid it.

const state = proxy({
  foo: 'hey',
  toJSON: () => JSON.stringify(state),
});

Replies: 2 comments 1 reply

Comment options

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

Answer selected
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
1 participant