Skip to content

Getting a warning when used observables in functions inside react components #3377

Answered by urugator
MetaVII asked this question in Q&A
Discussion options

You must be logged in to vote

You're getting the warning, because console.log isn't synchronous, therefore it accesses todos outside observer.
Change it to console.log(mobx.toJS(todos)); and warning is gone. The toJS will run as part of observer, subscribing to todos and anything within, console.log later prints the returned non-observable copy.

Replies: 1 comment 1 reply

Comment options

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

Answer selected by kubk
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