-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Big change] Migration to React Hooks #856
Conversation
Hi @da-h, this is really exciting! Just getting back from a long vacation, but I'll jump into reviewing this as soon as I'm caught up with everything. |
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.
Alright, sorry this took so long to get back to @da-h. Overall though, this is an amazing change. Honestly I have an easier time parsing through and reading your new take on the code than I do trying to understand the old code, and I wrote most of the original stuff! (albeit years ago now)
Specifying to call stopPropagation only in PropertiesPane solved the issue. (However, I do not really understand why. Any idea?)
Are you saying that, if you add the blurStopPropogation
chain to the underlying PropertyItem
, but then only set it in PropertiesPane
, that fixes both the issue in PropertiesPane
and in the regular Pane
? That's really weird, and would point me to a difference in event propagation behavior by default in the Pane
. Might remain something of a mystery...
As no functionality should have been changed the cypress tests should succeed.
This is a huge accomplishment really, there was a lot of code here to keep right, so the fact that tests are still passing is great.
} | ||
|
||
handleDownload = () => { | ||
function ImagePane(props) { |
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.
As a tiny nit, a common react pattern when we know that this component uses specific props
and the downstream component (that we extend to with {...props}
) uses different ones is to do parameter de-structuring inline, like:
function ImagePane({ known, used, values, ...props})
This both clarifies values that this component needs as well as prevents them from being passed down.
In this particular class though, there's a lot of stuff that is being used here and still passed down to the pane, so for these I like doing a de-structure right at the top:
const {appApi, height, width, other, args, that, are, needed} = props;
This still makes it easy to reason about the required prop arguments upfront.
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.
Thanks for pointing this out, I did not know that syntax, yet! :)
I have adapted all Components to include such a de-construction of all prop-values (if possible) at the start of the function.
I have added that change as a new commit for easier inspection of the changes.
(If you want, I can squash these changes also into the respective previous commits before merging).
Hey there!, this time it was me who was on the road. :)
It seems so. I would have expected that both Types ( |
This is strange. The test on the current master branch (without the changes of this PR) has failed. Let's see if I find something. |
Ah too bad, thought the "update to master" button would rebase instead of creating a merge commit. Too keep things clean, I can remove the merge commit tomorrow an rebase the changes. (Unfortunately, i do not find a possibility to do that on the road). |
Strange thing that the test fails again, especially because I have tested both this PR and the fix on my github fork and also locally without any failing test. |
No worries here, I've been able to keep track! |
ebd3b54
to
d940252
Compare
Hey, just found the errors & resubmitted the fixed PR. short summary:
On the consistency of the tests: (In the example image below, all branches test the exact same changes. Here, the |
d940252
to
bdeb0ec
Compare
Rebased onto master. |
Another great QoL change for the codebase here, thanks again @da-h! |
This PR migrates most React components of this project to the newer hook based react style.
Description
This PR applies three main changes to
js
files of the code base:EmbeddingsPane
andApp
) to hook based react functions.tbody
tags inPropertyLists
. (The browser console did mention this in its warnings).key
-attributes inPane
. (The browser console did mention this in its warnings).Pane
and inPropertiesPane
.Specifying to call
stopPropagation
only inPropertiesPane
solved the issue. (However, I do not really understand why. Any idea? 😅 )I.e.
getWindowSize
andgetContentSize
have not been used inPane
&resize
has not been used in both,Pane
andPropertiesPane
.ImagePane
)ImagePane
).Notes:
js: code normalize X
).Feel free to remove or adapt in case something does not meet the code style of the project.
Motivation and Context
This change has been suggested in a previous discussion, and I am also sure that future changes would benefit of a more up-to-date code base.
How Has This Been Tested?
No additional testing. As no functionality should have been changed the cypress tests should succeed.
Types of changes
Checklist: