需要上下文`getStore`

时间:2015-06-30 12:28:55

标签: reactjs fluxible

Fluxible@0.4.10

我遇到了一点错误

Warning: Failed Context Types: Required context `getStore` was not specified in `StoreConnector`. Check the render method of `NavIndexItemTheme`. /client-interface/node_modules/fluxible/addons/connectToStores.js:48 storeInstances[storeName] = this.context.getStore(store); ^ TypeError: undefined is not a function

事实上,我有这个:

components
          |_NavIndexItemTheme.jsx
...
templates
         |_tp1
              |_node_modules
              |             |_react
              |_Index.tpl.jsx

Index.tpl.jsx

import React from "react";
import NavIndexItemTheme from "../../components/NavIndexItemTheme";

export default function(props) {
    return (
       <div className="index">
         <div className="wrapper flex fdc fas">
            <h1>Hello</h1>
            <NavIndexItemTheme />
          </div>
        </div>
    );
 }

如果我将 node_modules 文件夹删除到 tp1 目录,则没有错误。为什么这个目录会导致错误!!!

1 个答案:

答案 0 :(得分:1)

您不应该在一个项目中保留多个node_modules文件夹,这会导致您的依赖项解析模糊不清,从而导致混乱。看起来您的Fluxible模块的版本与项目根目录NavIndexItemTheme中使用的版本不同。

  1. 至少使用Fluxible 0.4.11,其中context.getStore was added
  2. 删除templates/tp1/node_modules
  3. 确保您的高阶组件(通常为Application)包含在provideContext()的{​​{1}}函数中。