Search code examples
reactjsfluxible

Require context `getStore`


I meet a little mistake with 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

In fact, I have this:

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

In 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>
    );
 }

If I delete the node_modules folder to tp1 directory, there isn't mistake. Why this directory causes mistake !!!


Solution

  • You should not keep multiple node_modules folders inside of one project, this introduces ambiguity to your dependency resolution, which leads to mess. Looks like your Fluxible modules are of different versions than the one used in project root and NavIndexItemTheme.

    1. Use at least Fluxible 0.4.11, where context.getStore was added.
    2. Remove templates/tp1/node_modules
    3. Ensure that your higher-order component (usually Application) is wrapped in a provideContext() function from fluxible/addons/.