mobx-react icon indicating copy to clipboard operation
mobx-react copied to clipboard

Enzyme's shallow() doesn't recognise the component when decorated with both @observer and @inject

Open leudanm opened this issue 9 years ago • 3 comments

So the workaround for this was usually to use @observer(['store1', 'store2']). Since this approach is now deprecated and probably will be removed at some point, this will be quite an issue.

This is the error: Invariant Violation: Component(...): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.

As soon as I remove one of the decorators, everything works as expected.

leudanm avatar Dec 09 '16 14:12 leudanm

see the recently closed issues

Op vr 9 dec. 2016 15:17 schreef Daniel Leu [email protected]:

So the workaround for this was usually to use @observer(['store1', 'store2']). Since this approach is now deprecated and probably will be removed at some point, this will be quite an issue.

This is the error: Invariant Violation: Component(...): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.

As soon as I remove one of the decorators, everything works as expected.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mobxjs/mobx-react/issues/178, or mute the thread https://github.com/notifications/unsubscribe-auth/ABvGhPiusQ9PC6k1KQBLaZ62aPIGeGZXks5rGWLfgaJpZM4LI-s6 .

mweststrate avatar Dec 09 '16 15:12 mweststrate

(on mobile) short answer use .wrappedComponent

Op vr 9 dec. 2016 16:38 schreef Michel Weststrate [email protected]:

see the recently closed issues

Op vr 9 dec. 2016 15:17 schreef Daniel Leu [email protected]:

So the workaround for this was usually to use @observer(['store1', 'store2']). Since this approach is now deprecated and probably will be removed at some point, this will be quite an issue.

This is the error: Invariant Violation: Component(...): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.

As soon as I remove one of the decorators, everything works as expected.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mobxjs/mobx-react/issues/178, or mute the thread https://github.com/notifications/unsubscribe-auth/ABvGhPiusQ9PC6k1KQBLaZ62aPIGeGZXks5rGWLfgaJpZM4LI-s6 .

mweststrate avatar Dec 09 '16 15:12 mweststrate

Thank you!

leudanm avatar Dec 09 '16 19:12 leudanm