2017-01-05 2 views
0

(の反応コンテキスト内でそのプロパティを格納)mobx-reactProviderコンポーネントに依存しない@injectデコレータを実装するための潜在的な問題は何ですか?なぜの反応コンテキストを使用する必要性を注入mobx?

injectの使用量がこのようなものになるだろう:

// MyComponent.js 

import { authManager } from './services'; 

const MyComponent = ({ authManager }) => ...; 

export default inject({ authManager })(MyComponent); 

それはちょうどコンポーネント小道具とそのパラメータをマージします。

答えて

0

あなたは、噴射機能への最初の引数として関数を渡すことができます。 https://github.com/mobxjs/mobx-react#customizing-inject

import { authManager } from './services'; 
inject(_stores => ({ authManager }))(YouComponent); 

それは文脈に依存しません、それはちょうどあなたの小道具に返されたオブジェクトをマップします。

私はそれをテストしなかった

関連する問題