Using React 16 to open new window with shared state
hackernoon.com
hackernoon.com
That was I can abstract it into convenience classes for connecting, event listening, etc.
I have done my own take at this since some times but vanilla only https://github.com/grz0zrg/wui where any of the dialog widget can be detached off the main window keeping the same content & state. A feature i never saw in any web apps but saw often on desktop apps, nice to see that some peoples think of this sort of thing with cleaner approach!
Yep, this is precisely the use-case I would have for this in loom-viewer[0], a SPA data viewer I'm developing for the Loom file format[1] (think large genomic data matrices + metadata). It has a lot of scatter plots and bar charts, and for people with multiple monitors using a separate window as a pop-out would be quite beneficial. It also would make it easier to print out the graphs (which I find silly, but it's a thing researchers do).
I've looked at golden-layout before, but it doesn't play nice with redux at the moment[1]. Since I'm already on React 16 this might be what I'm looking for.
Well, note that I say that golden-layout does not play nice with Redux, not the other way around. It's not Redux being problematic here, as far as I can tell.
There's an open issue on their github repo asking for examples of how to integrate it:
https://github.com/deepstreamIO/golden-layout/issues/280
Maybe things have improved since I've last looked at it, but when I tried a few months ago, it seemed like it would require quite a bit of change in my code to get it up and running
By comparison, this new React 16 solution looks like it's a lot simpler to integrate in my existing code.
You have three projects/clients/orders/enquiries/purchase orders/invoices/etc. You want to compare them/discuss them/etc.
You need to be able to switch between them.
It is very common for those kind of apps to get requests that lists/tables open a new window on link click.
Events fired in the portal bubble up the vdom tree up to the component that mounted the portal (and then further upwards to the main vdom root), rather than up the real dom up to the popup window root.
<Parent>
<MyPortal root={element}>
<h1>Howdy!</h1>
</MyPortal>
</Parent>
Where MyPortal actually renders its children in another element. Single component tree, multiple DOM roots. What portals add is the propagation of events through the portal.https://flems.io/#0=N4IgZglgNgpgziAXAbVAOwIYFsZJAOgAsAXLKEAG...
Probably more of a chrome bug though I guess, it should inherit script blocking from the spawning page.
How were React devs doing modals, etc before?
Alternatively, don't bother with all of this and just mount the modal into your children. Use CSS `position: absolute/fixed` to position it. Of course this assumes your ancestor elements don't have certain properties like `position: relative` or `transform` set, but this is usually not a problem.
Anglar 1 was around for a while. There was a big fuss about Angular 2 being incompatible, and before I have had a chance to look at it, we are on Angular 4.
Now we are on React 16.
As if the JavaScript ecosystem wasn't bad enough, we now seem have an extra problem of completely silly release numbers. (I do 80% back end work, but in this day and age its hard not to use JavaScript. I took an interest in these frameworks a couple of years back and didn't gt much chance to follow up since then. Version numbering like this discourage me from finding out more.)
They're on v16 because they increment the number any time they make a change that isn't 100% drop-in backwards compatible with the previous version, with a deprecation cycle when possible beforehand. Apps that function without deprecation warnings can update immediately when a new release drops.
Ultimately they are where they are because they were of a change they made when they released v15. Really, it's more like v3, but they kept the numbering consistent with how people talked about it. https://reactjs.org/blog/2016/02/19/new-versioning-scheme.ht...
It's the same reason chrome is on 62 and Firefox is launching 57 at the end of the month.
Semantic versioning gets bigger numbers faster, but it's better for developers.