mirror of
https://github.com/kusti8/proton-native.git
synced 2026-05-15 14:15:50 -06:00
[GH-ISSUE #180] Reconciler rerendering unchanged elements? #115
Labels
No labels
bug
documentation
enhancement
libui issue
pull-request
question
wait for libui implementation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/proton-native#115
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mischnic on GitHub (Oct 7, 2018).
Original GitHub issue: https://github.com/kusti8/proton-native/issues/180
Hot reloading is nearly working (https://github.com/mischnic/proton-hot-cli), but there is an issue when reloading a
Windowcomponent.On macOS, the window position resets to the bottom left corner and on Windows, a new window is created on every update. This is because a new
libui.UiWindowis created every time an update occurs (even though the props didn't change). A workaround is putting all component inside of the window into a new file, so that the component containing theWindownever gets reloaded itself.This is how it works internally:
gets turned into
@mischnic commented on GitHub (Oct 12, 2018):
I've reduce the code a more (full repo: https://github.com/mischnic/proton-reload-issue - just run
npm start):Changing the button text inside the MyApp component recreates the window, although only the button text changed.
@mischnic commented on GitHub (Oct 13, 2018):
This works fine though (without the window inside MyApp):
@kusti8 commented on GitHub (Oct 16, 2018):
Huh, interesting. It works fine for me on Linux. I don't have access to mac right now, but I'll try it out on Windows.
@mischnic commented on GitHub (Oct 17, 2018):
Really? Ubuntu in VirtualBox (so behaves just like macOS - the window position resets):
@kusti8 commented on GitHub (Oct 18, 2018):
Yeah that's my bad. I was using a tiling WM so it appeared different. AFAIK, the reconciler looks right. What I think might be happening is that when the state changes, it sees it as an entirely new object, so it re-renders everything rather than diffing it. I don't know if this same thing happens with React/React-Native because there's no concept of windows there.
@mischnic commented on GitHub (Oct 19, 2018):
I'll have to check whether React removes and readds a html element in a situation like this...
@mischnic commented on GitHub (Oct 19, 2018):
Yes, it does 😞.
I guess it's because to React, it looks as if a completely different component is being rendered (because
MyApp_old !== MyApp_new).@mischnic commented on GitHub (Oct 19, 2018):
But why even? A different component could render a very similar tree and diffing that would be more performant than just replacing.
@mischnic commented on GitHub (Oct 23, 2018):
Why does the diffing algorithm decide to remove and replace the
bnode?@mischnic commented on GitHub (Oct 31, 2018):
https://reactjs.org/docs/reconciliation.html:
Not sure how to circumvent this. Tricking React into thinking that the type didn't change....
@mischnic commented on GitHub (Nov 3, 2018):
Dan Abramov on Twitter:
@kusti8 commented on GitHub (Nov 3, 2018):
Cool. React made a blog post when they added hot reloading about how they did it and it was pretty convoluted. I can't find it right now.
@mischnic commented on GitHub (Nov 3, 2018):
I think I read most of these while developing proton-hot-cli. But there is one big issue: local state in reloaded components is always lost.
@kusti8 commented on GitHub (Jan 19, 2020):
Proton Native V2 is now released! If the issue still occurs in the new update, please open a new issue.