-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debugging in Chrome using Hooks #104
Comments
Hey, I looked into this briefly and found a few things. First, it is possible to find the values, but not in a very scannable form: That's because It's not the most elegant place to read it (compared to how you see the value of Second, It's currently not possible to log the name of the variable ( Perhaps, somehow, it could be possible to overwrite the Third, For a while I've been thinking of creating of kea's own devtools that could provide all this information and much more... although then probably not via an integration into react-devtools... but through it's own extension. This project also hasn't gotten too far. So far what I have is this: https://gist.github.com/mariusandra/0b3e63e70b68f86e5dc5ad714341bed9 If you import it and add the Eventually this could be extended into something that shows a nice diagram between all the react components that use (or are wrapped by) any logic, including what values are connected/used... but it's far from there. Any help making this into a real useful tool is of course appreciated, but not expected. ... Sorry I couldn't give a better answer to your question though. Once the issue with react-devtools gets a resolution, it should be easier to find some solution. Actually, thinking about it, a hack could be to replace this code: Object.defineProperty(response, key, {
get: () => useSelector(logic.selectors[key])
}) with: Object.defineProperty(response, key, {
get: () => {
if (getContext().options.debug) {
useState(`Getting value: ${key}`)
}
return useSelector(logic.selectors[key])
// and maybe use and update another ref if the returned value changes...
}
}) ... but that seems way too hacky to me :) |
Thanks for the quick response! The dev tools extension would be great. Will grab it and play around with it. |
Cool and thank you! :) Be aware that you might need to dive into kea's internals to make any sense of it... and there might be data that's hard to see right now, for example the same {
get: () => {
if (window.__KEA_DEVTOOLS__) {
// log that we are using this value somehow
// to make it visible in the devtools
}
return useSelector(...)
}
} I'm not sure at this point what is needed to bring the dev tools to the same quality that the react and redux devtools have... In any case, thanks for trying it out! |
We've been using Kea for well over a year and recently upgraded to 1.0 and LOVE the changes. However, we've found it challenging to debug with the React Dev Tools and wondered if anyone has any suggestions on how to see values from the
useValues
hook in the inspector.I have created a POC with the old and new syntax here (forked from a training resource our team uses source) that you can use to see the issues we're having.
When inspecting the legacy component, you can clearly see the props Kea exposes.
However there isn't a clear way to be able to see the data from the hooks.
Does anyone have any tips on being able to effectively debug the new Hooks?
The text was updated successfully, but these errors were encountered: