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

Improve context name display #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

BernieCr
Copy link

This improves how contexts that are not explicitely named (e.g. debug_id8 etc.) are displayed in the sidebar.
The idea was to simply show the first three keys of the context object. By this you usually get a pretty good idea about what context it is.

Before After
Screenshot 2021-02-09 at 18 07 56 Screenshot 2021-02-09 at 18 07 17

@deeppatel234
Copy link
Owner

Hello @bernhardc ,

Thank you for contributing to react-context-devtool.

you can assign a display name to the context using https://github.com/deeppatel234/react-context-devtool#set-display-name-for-context-api.

we can not show object first n keys as display name because the value is not fixed to object every time. it should be number, string, function only. and this computation is to do some overhead to the rendering of your app.

@BernieCr
Copy link
Author

Well yes you can manually assign a display name, but this PR would provide some convenience out of the box without needing that manual step. Also there may be some context from external libraries where you can't set the display name.

Also as you can see in the code, there is already a check whether the context value is an object.
I also don't see any performance implications - why would that Object.keys() call introduce some measurable overhead?

@t18n
Copy link

t18n commented Jul 7, 2022

It would be useful to have a way to sort/group Contexts. In the screenshot below, you can see that MUI contexts are mixed up with user-defined contexts, which makes it difficult to quickly debug. If I prefix it with something, sometimes the names are randomly listed as well. Some basic grouping/filter based on name would be awesome.

image

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

Successfully merging this pull request may close these issues.

3 participants