-
-
Notifications
You must be signed in to change notification settings - Fork 349
inject function introduces conflict with new React static context #612
Comments
I might be mistaken, but I think your problem is not Provider / inject, but
combining React.createContext (new React api) with static ContextTypes (old
React api), and you should be using MyContext.Consumer instead
Op vr 23 nov. 2018 om 17:25 schreef Zisis Zikos <[email protected]>:
… I'm trying to use mobx-react inject function along with the new static
context of React, and I'm getting this error:
Warning: inject-MainCompClass declares both contextTypes and contextType
static properties. The legacy contextTypes property will be ignored.
Check the console at this example <https://codesandbox.io/s/wq5q96q807>.
I guess that inject uses the old React context style, and React decides
to use only the new style used by the component. This has as a result, the
mobx store to be undefined.
Versions:
react: 16.6.3
mobx: 5.6.0
mobx-react: 5.4.2
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#612>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABvGhIzrCtvt23RGphjSuLhrSUayn16lks5uyCGJgaJpZM4Yw5va>
.
|
I think @zisiszikos is right.
In my case, that make the mobx contextTypes to be ignored To reproduce, just try to play arround with the new feature |
This library should use https://github.com/jamiebuilds/create-react-context so it can work with next react context. |
needs hoist-non-react-statics upgrade |
@zisiszikos try adding
to your package.json. This should force this library to use the latest hoist-non-react-statics since they haven't upgraded. |
apparently observer just breaks classes that use |
Reproduced, thanks for reporting. Will release a fix soon |
Fix has been released as 5.4.3 |
Perfect! I confirm that is working now. |
I'm trying to use mobx-react
inject
function along with the new static context of React, and I'm getting this error:Warning: inject-MainCompClass declares both contextTypes and contextType static properties. The legacy contextTypes property will be ignored.
Check the console at this example.
I guess that
inject
uses the old React context style, and React decides to use only the new style used by the component. This has as a result, the mobx store to be undefined.The text was updated successfully, but these errors were encountered: