mobxjs / mobx-react-devtools

[DEPRECATED] Tools to perform runtime analyses of React applications powered by MobX and React
MIT License
1.23k stars 49 forks source link

Uncaught Error: [mobx] Cannot obtain atom from undefined #92

Closed corysimmons closed 6 years ago

corysimmons commented 6 years ago
import React from 'react'
import DevTools from 'mobx-react-devtools'
import { observable } from 'mobx'
import { observer } from 'mobx-react'

@observer
class App extends React.Component {
  @observable count = 0

  inc = () => {
    this.count++
  }

  dec = () => {
    this.count--
  }

  render() {
    return (
      <div>
        <h1>{this.count}</h1>
        <button onClick={() => this.inc()}>+</button>
        <button onClick={() => this.dec()}>-</button>
        <DevTools />
      </div>
    )
  }
}

export default App

...using rewire mobx.. It seems to work. If I click the last icon, I get:

image

The undefined looks a bit worrisome, but then I click the middle icon and I get this:

image

What am I messing up? I'm following the Mobx course on Egghead. It's probably a bit dated.

benmccormick commented 6 years ago

I'm seeing this on an application where it was previously working after upgrading to MobX 5.

From package.json

    "mobx": "^5.0.2",
    "mobx-react": "^5.2.3",
    "mobx-react-devtools": "^5.0.1",
Lyfme commented 6 years ago

same here. how to solve

deadcoder0904 commented 6 years ago

Exactly same issue https://codesandbox.io/s/7q61kvkl0

dubrovsky-kiril commented 6 years ago

Same for me with next dependencies: "mobx": "^5.0.3", "mobx-react": "^5.2.3", "mobx-state-tree": "^2.2.0", "mobx-react-devtools": "^5.0.1"

lvguowei commented 6 years ago

Same problem here. What is it?

max9599 commented 6 years ago

Same

"mobx": "^5.0.3",
"mobx-react": "^5.2.3",
"mobx-react-devtools": "^5.0.1",
corysimmons commented 6 years ago

Can you guys pipe down and just put 👍 on my issue so I don't get pinged with "Me too!" and "Same!" every other day?

I'd like to stay subscribed to this in case someone has something valuable to say.

mweststrate commented 6 years ago

Hi folks! Sorry for the late follow up, there was some confusion about the maintenance. I'll review the open PRs and will release them soon. But if someone would be interested in actively maintaining this package that would be great! Should be a pretty small effort but having a single person overseeing the thing that would be great :)

mweststrate commented 6 years ago

Released as mobx-react-devtools@6.0.1

corysimmons commented 6 years ago

Thanks Michel. We're using Mobx pretty extensively at my new gig. Once I become super comfy with it I'll give serious thought to helping out and freeing you.

cweekly commented 5 years ago

I'm on mobx-react-devtools@6.0.3, and seeing the same error:

Uncaught (in promise) Error: [mobx] Cannot obtain atom from [object Object]....

Note I've dug around a bit and found what looks to be a related issue from 2016 in the main mobx project: https://github.com/mobxjs/mobx/issues/288#issuecomment-223778275
... indicating a possible workaround of explicitly referencing a given class's properties (e.g. via console.log) before observing them. I tried that, to no avail. So for now, I'm resorting to simply removing mobx-react-devtools. ):

If I find time to post a simple test case to reprod, I will, otherwise it's just FYI, and thanks for a mostly-awesome tool.

mweststrate commented 5 years ago

Please refrain from commenting on closed issues, it is quite unlikely somebody will see them. Just open a new issue (and follow the template).

On Wed, Feb 13, 2019 at 11:42 PM Chris Weekly notifications@github.com wrote:

I'm on mobx-react-devtools@6.0.3, and seeing the same error:

Uncaught (in promise) Error: [mobx] Cannot obtain atom from [object Object]....

Note I've dug around a bit and found what looks to be a related issue from 2016 in the main mobx project: mobxjs/mobx#288 (comment) https://github.com/mobxjs/mobx/issues/288#issuecomment-223778275 ... indicating a possible workaround of explicitly referencing a given class's properties (e.g. via console.log) before observing them. I tried that, to no avail. So for now, I'm resorting to simply removing mobx-react-devtools. ):

If I find time to post a simple test case to reprod, I will, otherwise it's just FYI, and thanks for a mostly-awesome tool.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/mobxjs/mobx-react-devtools/issues/92#issuecomment-463405789, or mute the thread https://github.com/notifications/unsubscribe-auth/ABvGhGx_jaYF4q6ZlG_UpQSC7dDi1qtDks5vNJTmgaJpZM4UzUeW .

clehene commented 4 years ago

Please refrain from commenting on closed issues, it is quite unlikely somebody will see them. Just open a new issue (and follow the template).

@mweststrate Google still works after closing the github issues you know ;). It may not be convenient from a maintenance perspective, but as a "knowledge base" it's useful to get more context expecially when you land here while googling for your error.

dirkpostma commented 2 years ago

I got this error when defining onBecomeObserved. I solved it by moving the the onBecomeObserved after makeAutoObservable(this)