keajs / kea

Batteries Included State Management for React
https://keajs.org/
MIT License
1.94k stars 51 forks source link

Error: [KEA] Can not find path "kea.inline.2.01F5GZMSKVYQS0SD7M823JDN8P" in the store. #130

Closed Buzzkill-McSquare closed 3 years ago

Buzzkill-McSquare commented 3 years ago

I'm trying to write a form that connects to a bunch of other logics that are responsible for resources. Initially I tried using the connected logics implcitly;

selectors: {
  example: [
    () => OtherLogic.values.data
  ]
}

With the above kind of implementation I get the following error;

TypeError: _OtherLogic__WEBPACK_IMPORTED_MODULE_3__.OtherLogic.selectors is undefined

After investigating closed issues I found one that seemed similar to that problem and updated my implementation in line with one of the comments;

selectors: ({ props }) => ({
  example: [
    () => OtherLogic(props).values.data
  ]
})

But this gives me the following error in the title of this issue. My problem is that I'm expecting the path to not exist in the store yet, as this composed logic is the entry point of a page and my assumption is that the store would be added to as a result of using it.

Is there a way to initialize connected logic state from the "parent" logic? Do I need to explicitly declare the connected logic in my component before using the parent logic?

mariusandra commented 3 years ago

I think you have a typo there. Inside selectors, instead of using OtherLogic.values.something, you should use OtherLogic.selectors.something. This way the logic should automatically be added to the store when probed.

Alternatively, you can also use explicit connections.

See the connecting logic together section in the docs for more info.

Buzzkill-McSquare commented 3 years ago

Thanks, that clears up the issue. I think I landed on this solution through trial and error but I'm glad to understand the mechanism now.