-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Support for inspecting Immutable.js objects #149
Conversation
Hmmm. So that looks reasonable. Thanks for putting this together! |
That makes sense to me. Do you have a sample plugin I can consult? |
return data.constructor.name; | ||
} | ||
}, | ||
shallowToJS(dataStructure: any): any { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I ask your rationale behind providing a shallowToJS
here but not a deepToJS
that calls Iterable.toJS()
? For example, if a particular prop is an Immutable.KeyedIterable
with a property value that is itself an Immutable object, then it seems that shallowToJS
would not convert the property value to a mutable object.
Edit - I see that your test for this module already asserts the above. Would it not be valuable to do a deep .toJS()
call for any immutable object so that the dev tool user can more easily navigate nested immutable properties and state values?
Edit 2 - After digging a bit deeper, it looks like you're doing a shallow conversion at each level so that the user can easily see whether or not some nested property is immutable or not while also being able to easily inspect its child properties. If that's the case, 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was just about to write that. The reason in edit 2 is precisely why.
@garetht, I believe @jaredly is referring to the idea of I'm not sure what the most appropriate way to implement these utils as a conditional functionality is, but one option might be to render an |
@garetht, @jaredly, I took a pass at implementing the "inspect immutable objects as js" functionality as an optional setting. This pull request creates a new checkbox at the top of |
Yeah -- I'm hesitant to bake in Immutable support; it would be awesome to see this as a plugin; I'll take some time this weekend to figure out what that would look like |
👍 I'm looking forward to this! |
I decided against using Immutable for this very reason. It really renders the dev tools useless in inspecting data. As long as immutability is being encouraged through projects like redux, I think the few extra lines of code should definitely be baked into the devtools. |
You can always select an object in the dev tools and query it using $r I But yeah it's definitely not as quick as it could be On 15 January 2016 at 04:41, Zack Argyle notifications@github.com wrote:
|
@zackargyle - You could always clone @garetht's version of the React devtools (ie. the branch this pull request points to) and try it out :) |
As for the feature, I think it is really necessary we get something like this merged. I think we should strive to support any iterables, and not just Immutable.js specifically. As an example, react-json-tree checks whether something has an iterator and handles iterable nodes in a specific way. I think we should do the same here. Would you like to look into reworking this PR to support arbitrary iterables? Thanks. |
Closing as there is no response from the author. |
A more generic support for this landed in #459. |
This pull request makes changes meant to support the functionality requested for in #52.
Changes Made