-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix #388 : Displaying date appropriately #559
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! If you are contributing on behalf of someone else (eg your employer): the individual CLA is not sufficient - use https://developers.facebook.com/opensource/cla?type=company instead. Contact cla@fb.com if you have any questions. |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
This is not fixing the problem. You fixed the example to not use a date as a prop. Instead we need to fix the DevTools to display dates correctly. Once that is fixed, it's fine to revert any changes to |
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.
See comment above
Oh, im confused. Where should I be making the changes? |
DevTools uses a bridge to serialize objects and later deserialize them. Serialization happens in It is probably worth introducing a new type ( I hope this helps! |
(Note I'm not sure myself. I'd start with adding a special case to |
No worries, I'll dig into this. Should I remove the changes i made above? |
You'll want to keep a date prop there so that you can verify your next fixes work. But you should remove |
Got it. Question: why are you referring to it as props when it's in the |
Ah, I missed that. I suggested adding it to props initially so that's what I was referring to. It doesn't matter really—the way you added it to state also works for testing. |
@gaearon is that a step in the right direction? I put a console log on line 44 of |
agent/dehydrate.js
Outdated
@@ -40,6 +40,13 @@ function dehydrate(data: Object, cleaned: Array<Array<string>>, path?: Array<str | |||
type: 'function', | |||
}; | |||
} | |||
//check if data is of type date. typeof doesn't support Date, so instanceof is being used | |||
if (data instanceof Date) { |
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.
I'm not sure this will work across iframes. Let's use data != null && typeof data == 'object' && Object.prototype.toString.call(data) === '[object Date]'
. See explanation here. This is what Lodash does, too.
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.
Done. Should I be able to console.log and see where it reaches?
agent/dehydrate.js
Outdated
@@ -40,6 +40,13 @@ function dehydrate(data: Object, cleaned: Array<Array<string>>, path?: Array<str | |||
type: 'function', | |||
}; | |||
} | |||
//check if data is of type date. typeof doesn't support Date, so instanceof is being used |
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.
Let's remove this comment because it just duplicates the code.
Here's what I did: I am running:
In the console, I see both logs: I am also seeing the date in the inspector: So I think you're going in a right direction, and now need to add code to the |
simply copy the |
@gaearon Thanks for the suggestion. I got really confused with all the scripts to start the dev environment which is why I could not verify if the code was working. Just pushed a few changes. also added a random color, if you want a specific one let me know. (is hex ok?) |
If that works then yes. |
Do you want another PR for that?
…On Wed, Feb 22, 2017 at 1:03 AM Dan Abramov ***@***.***> wrote:
simply copy the build.sh in test/example right?
If that works then yes.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#559 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFmqGd3TG399n5FCnUjnhnSSxqUv1kA0ks5rezwggaJpZM4MGhaW>
.
|
Yea |
Sounds good, will do so. Any thoughts on this PR? Now that we're toward the end of this, I can remove the |
I think it's fine to leave |
Sounds good! @gaearon Does this look good to you? I'll pull master and create another PR for the |
I'm a bit busy this week but I should be able to look at this next week. |
I tested this by creating a new to do item and inspecting the todos array. |
This is exactly what I see. Oh one second, is the |
Well, the problem is this doesn’t really show Dates specially, it just shows an object instead of them. What we want is to show the date itself—this is why we need to modify the frontend to check for this special type, and display it specially. I see you added the code there, but have you verified it actually runs? Maybe there’s some earlier conditions that prevent it from running. The end goal is to display Dates same way Chrome displays them: |
Oh ok. Sorry about that, I'll get to this tomorrow if it's ok. It's 4 15 am where I am. 😄 |
Yea, no worries. Thank you! |
Do you need any help? |
Hi Dan, sorry for the delay. Got caught up in work, looking at this now. |
@gaearon is the |
It's up to you—all I care about is the end result :-). I just suggested one way of producing a string like this out of a date. |
Alright, so I've been able to debug that it doesn't hit any of the checks in
it returns Should I modify I'm not sure why the checks are not getting passed. |
Would editing it give you anything? I presume it returns |
Hmm. So
that's what we're aiming for right? This is the line it's failing at after debugging:
|
Maybe? I don’t know 😄 . You have more context on this code than I do. |
All I’m saying is: try to see how other special types (e.g. array) work, and follow the same principle. I don’t know this code well so following my suggestions verbatim is probably not the best idea. |
Sounds good.
Could you tell me how to debug arrays, objects? |
I'm not sure what you're asking. I think |
Right, I saw that. For example, to test the date formatting I would enter a new todo item in the input box and then view the todos state (and inspect the time property). Similarly, I was wondering how would I test the object or array? I know it's being handled, but I want to attach a debugger and step through |
You can set a breakpoint in those places in |
I’m closing since this got stale. Thanks for your effort! |
PR for #388