-
-
Notifications
You must be signed in to change notification settings - Fork 352
Adding observer
affects original component
#697
Comments
I don't follow what's the issue. If you use exported Can you elaborate more please? |
Seems to be done deliberately, check this PR |
It is affected, take a look at - <div>
- Test
- </div>
+ <Observer>
+ <Component />
+ </Observer> |
Is this a viable workaround? |
@sergei-startsev I am looking at a snapshot file and I don't see any Observer there. That's why I am confused. |
@urugator Line 140 in 4904b62
It seems to me that a new inherited class has to be created instead of changing prototype of the original: Line 126 in 4904b62
|
@FredyC |
I see your step, but writing something in readme does not make it true 😆 Why test snapshot is showing something else? |
Have you checked my first comment? |
@FredyC I've added both examples with
Just run steps from |
It would be much more helpful if the snapshot would be showing an actual problem. Either way, check the discussion on why the change you are suggesting was reverted. If you have idea how to make that work, PR is most welcome. |
See also #703, this behavior might need to be reverted anyway (not that it really does make a fundamental difference, v5 is also patching classes, but at least the behavior would be the same) That being said, this problem is unavoidable from an implementation level, as we have to reach into some of the React internals. If you want a pure declaration: don't use |
Fixed in 6.1.0 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or questions. |
What is the current behavior?
Adding
observer
wrapper affects originalrender
method. There's some regression after upgradingmobx-react
to version 6 caused by affecting the original (unwrapped) component.observableFoo.render
as well as originalFoo.render
is overridden by addingSince
observer
isn't pure, there's no possibility to reuse a component without mobx.Here's a repository with repro steps: https://github.com/sergei-startsev/mobx-react-observer
What is the expected behavior?
There's an expectation that adding
observer
wrapper should not affect the original component. E.g. addingobserver
wrapper in the default export below should not affect namedFoo
export:The text was updated successfully, but these errors were encountered: