0

我在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目录,则不会出错。为什么这个目录会导致错误!!!

4

1 回答 1

1

您不应该node_modules在一个项目中保留多个文件夹,这会给您的依赖关系解析带来歧义,从而导致混乱。看起来您的 Fluxible 模块的版本与项目根目录和NavIndexItemTheme.

  1. 至少使用 Fluxible 0.4.11,其中添加了 context.getStore
  2. 消除templates/tp1/node_modules
  3. 确保您的高阶组件(通常Application)包含在provideContext()来自fluxible/addons/.
于 2015-07-02T10:40:18.517 回答