freactal icon indicating copy to clipboard operation
freactal copied to clipboard

Shared(global) state for some use cases

Open pronevich opened this issue 8 years ago • 5 comments

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

pronevich avatar May 10 '17 11:05 pronevich

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!

divmain avatar May 27 '17 08:05 divmain

I'm going to reference some related discussions here:

https://github.com/mobxjs/mobx/issues/300 https://github.com/mobxjs/mobx/issues/605

stefanmaric avatar Oct 26 '17 00:10 stefanmaric

@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?

divmain avatar Nov 28 '17 09:11 divmain

Yes, exactly as you explain it

pronevich avatar Nov 30 '17 12:11 pronevich

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.

divmain avatar Dec 01 '17 19:12 divmain