Open pronevich opened 7 years ago
This is a tricky thing, and I'm not sure of the best way to go about accomplishing what you're attempting here. I'm not super familiar with Next.js yet, either, so it may take a bit of research before I come to a satisfying answer. If any other folks have ideas, I'm open to hearing them!
I'm going to reference some related discussions here:
https://github.com/mobxjs/mobx/issues/300 https://github.com/mobxjs/mobx/issues/605
@pronevich, I've been thinking about your question a bit more, and this stuck out to me:
reconciliation on whole components tree
Is this happening for you? Due to how state is injected into components, a piece of state that is 1) tracked at the top level and 2) changed, should not result in a full VDOM reconciliation. It will result in a state reconciliation, checking whether the change in state should result in any re-renders, but this should be much less expensive (and honestly, exactly what we want).
Am I understanding the issue correctly?
Yes, exactly as you explain it
Would you be able to provide a reduced repro? I'm definitely interested in seeing areas where the state reconciliation results in an unnecessary VDOM reconciliation.
As I understand, freactal provide only local state concept. Maybe it would be make sense to add possibility to share some state (example: between pages in next.js) without composition on app root for preventing reconciliation on whole components tree.
Here @divmain twits about it https://twitter.com/divmain/status/861077765830852608