hookstate
hookstate copied to clipboard
What is Error 110?
As funny as this is, what is error 110?
ERROR [Error: Error: HOOKSTATE-110 [path: /icons]. See https://hookstate.js.org/docs/exceptions#hookstate-110]
Error 110 is not listed: https://hookstate.js.org/docs/exceptions#hookstate-110
Ah I see:
- https://github.com/avkonst/hookstate/blob/c777715e3676f141555ecdfc15b3bfa199a01a10/core/src/index.ts#L1067
- https://github.com/avkonst/hookstate/blob/c9f9f7571465a8cf2497257d446ac71857d5b638/core/src/tests/Object.tsx#L465
So it happens when you try to get a function without first converting the object back from a normal state object, or something?
I have a similar problem.
Error: Error: HOOKSTATE-110 [path: /]. See https://hookstate.js.org/docs/exceptions#hookstate-110 at new StateInvalidUsageError (/home/xereda/desenvolvimento/repositorios/rch-frt-portal/node_modules/@hookstate/core/dist/index.js:488:23) at StateMethodsImpl.child (/home/xereda/desenvolvimento/repositorios/rch-frt-portal/node_modules/@hookstate/core/dist/index.js:1179:19) at Object.get (/home/xereda/desenvolvimento/repositorios/rch-frt-portal/node_modules/@hookstate/core/dist/index.js:1242:26) at CancelOrderModal (webpack-internal:///./src/components/CancelOrderModal/CancelOrderModal.js:36:44) at renderWithHooks (/home/xereda/desenvolvimento/repositorios/rch-frt-portal/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5658:16) at renderIndeterminateComponent (/home/xereda/desenvolvimento/repositorios/rch-frt-portal/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5731:15) at renderElement (/home/xereda/desenvolvimento/repositorios/rch-frt-portal/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5946:7) at renderNodeDestructiveImpl (/home/xereda/desenvolvimento/repositorios/rch-frt-portal/node_modules/react-dom/cjs/react-dom-server.browser.development.js:6104:11) at renderNodeDestructive (/home/xereda/desenvolvimento/repositorios/rch-frt-portal/node_modules/react-dom/cjs/react-dom-server.browser.development.js:6076:14) at renderNode (/home/xereda/desenvolvimento/repositorios/rch-frt-portal/node_modules/react-dom/cjs/react-dom-server.browser.development.js:6259:12)
@xereda If I remember correctly this happens if you have a state structure that contains a function.
@winrid I did downgrade to version 3 then it's working again
Correct. It is a new error from hookstate 4. Happens when you set to a state an object which has functions and after you attempt to get/call a function on state instead of obtaining the original value first. To do it right, you need to do instead: state.get({noproxy:true}).myfunction()
On Sat, Aug 20, 2022 at 12:46 PM Devon @.***> wrote:
Ah I see:
https://github.com/avkonst/hookstate/blob/c777715e3676f141555ecdfc15b3bfa199a01a10/core/src/index.ts#L1067
https://github.com/avkonst/hookstate/blob/c9f9f7571465a8cf2497257d446ac71857d5b638/core/src/tests/Object.tsx#L465
So it happens when you try to get a function without first converting the object back from a normal state object, or something?
— Reply to this email directly, view it on GitHub https://github.com/avkonst/hookstate/issues/324#issuecomment-1221191463, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA6JSVODN64K7KJZJ53T5ZTV2ATHZANCNFSM57CKT2YA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
@avkonst Hi Andrey, thank you for your message.
I'm not having a function property state.
hmm... @xereda could you please help me to resolve this problem? I think it might be a bug in Hookstate-4 which detects the case 110 incorrectly. Could you please let me know what your state object is and what functions you call to get this exception raised?
@avkonst You can debug where the exception happens like this:
find Store.prototype.get
in node_modules/@hookstate/core/dist/index.js
change to:
Store.prototype.get = function (path) {
var result = this._value;
if (result === none) {
return result;
}
path.forEach(function (p) {
if (result === undefined) {
console.log('???', path, p, new Error().stack);
}
result = result[p];
});
return result;
};
You will then get a stack trace and the path that is causing the failure.
@winrid thanks for the message. I know how to debug these problems. I do not know how to reproduce this problem. Could you please post a code sample which reproduces the problem?
@avkonst
I've upgraded to the newest version of hookstate and now I need to pass a callback (function) through a state property. How to do it correctly?
let state = useHookstate({ callback: () => { return 1; } });
state.get({ noproxy: true }).callback()