2

ビューからreduxストアに小道具を渡す方法に関するドキュメントを理解できないようです。

登録.jsx

import configureStore from '../store/configureStore';

ReactOnRails.registerStore({
  configureStore,
});

// This is how react_on_rails can see the HelloWorld in the browser.   
[...]

ビュー:

<%= redux_store('configureStore', props: { profile: current_user.profile }) %>
<%= react_component 'NewProjectApp' %>

私は今迷っています。反応コンポーネントでできると思いました{props.profile}

私のアプリには、1 つのストアを接続する複数のコンポーネントがあります。profile プロップにアクセスするためだけにレデューサーを作成する必要がありますか?

レデューサー:

[...]
const profile = (profile) => {
  console.log(profile)
  return " "
};

// exporting the combined reducers
// shorten:
// combineReducers({ profile });

[...]

奇妙なことに、私のコンソールでは、undefined2 回表示されてから 3 回目に表示されます。プロファイル オブジェクトが表示されます。は?HelloWorlAppレールに反応するデフォルトの例を変更することで、reduxがどのように機能するかをまだ学んでいます。

4

0 に答える 0