Skip to content
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

Improved react dev-tools support for hooks #37

Closed
orestis opened this issue Mar 14, 2019 · 3 comments
Closed

Improved react dev-tools support for hooks #37

orestis opened this issue Mar 14, 2019 · 3 comments

Comments

@orestis
Copy link
Member

orestis commented Mar 14, 2019

Opening this to start a discussion going, but it seems it's not going to be an easy one.

React dev-tools supports introspecting the props and hooks of a component. Props work relatively well, but unfortunately, hx hooks look a little bit opaque:

2019-03-14 at 7 46 AM

Observations:

  1. All the names are the same.
  2. The first State hook is a CLJS map, but it renders as "...". This could be fixed by using useDebugValue inside <-state, to do custom formatting (pr-str would be an easy first step).

There's more to research here, as even using React/useState with a JS object doesn't show any value.

@orestis
Copy link
Member Author

orestis commented Mar 14, 2019

This is relevant: facebook/react-devtools#1282

@lilactown
Copy link
Collaborator

facebook/react#15259

I created an issue for this in the React repo. I might create one in devtools as well. I hope they give us some way of customizing the display name of the hooks in devtools, otherwise this might always be gross for anything that compiles to JS.

@lilactown
Copy link
Collaborator

It isn't possible for hx to fix this completely, since the React dev tools output relies on the names of closures within the React component rendered. Unfortunately, ClojureScript's let introduces a new closure most of the time in order to avoid variables leaking. That's what those eval names are.

If/when ClojureScript moves to outputting let/const, we might be able to remove those closures from the JS output and thus flatten this a lot more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants