-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Done with the problem faced of loosing screen. #2491
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
Conversation
U may check @lindapaiste whenever u are free. |
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.
It looks like you're combining two approaches here. You are setting a maxSize
state but not ever using it. Instead you're setting the maxSize
of the SplitPane
directly from the window.innerWidth
.
The code that you have here will actually work, but in a way that is very roundabout. Resizing the window calls the resize
event handler, which calls setMaxSize
. That changes the state of the component and forces a re-render, so the props of the SplitPane
will get re-evaluated using the current value of window.innerWidth
.
To keep the code cleaner I recommend the following changes:
- Remove
window.innerWidth
as a dependency of theuseEffect
. You only need to add theresize
event listener once. The dependencies should be[]
or[setMaxSize]
(both will only evaluate the effect once). If that is confusing, consider that the handler could be written asconst updateInnerWidth = (e) => { setMaxSize(e.target.innerWidth); };
. - Assign the state to a variable
maxSize
and use this to control theSplitPane
:maxSize={maxSize * 0.965}
. - As I'm writing this, I realize the issue of having an
undefined
value the first render and now I suspect that you probably wrote it the way that you did to avoid getting anNaN
value from multiplication withundefined
. How about we set the initial value of the state from thewindow
?const [maxSize, setMaxSize] = useState(window.innerWidth);
I sincerely apologize for the delay @lindapaiste . Upon reevaluating my approach, I have recognized the shortcomings and made the necessary adjustments as per your guidance. Thanks for your suggestion. |
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 working on this! I'm going to merge this in as it seems to resolve the issue for now. Please feel free to add any further comments or changes before the next release around next Tuesday, January 16.
Thanks for the merge @raclim and I will definetly add any further changes before 16th of Jan. Really thanks for considering me. :) |
Fixes #2483
Changes: I have make the preview screen where we cannot loose it. Please check the video.
p5.js.Web.Editor.5.mp4
I have done my best to change it.
I have verified that this pull request:
npm run lint
)npm run test
)develop
branch.Fixes #123