These are chat archives for openseadragon/openseadragon

31st
May 2018
Ronn
@ronnross
May 31 2018 18:47
Hi! Is anyone using OSD with react?
Douglas Russell
@dpwrussell
May 31 2018 19:59
@ronnross Sure, but OSD is an "island" within React.
Ronn
@ronnross
May 31 2018 20:02
Yeah, I was just checking how other have got it working. I got it working using portals in react 16.3
Just checking if there was a preferred way to handle it.
Douglas Russell
@dpwrussell
May 31 2018 20:03
@Ronn awesome, I did not know about Portals. This looks like a much better way!
Actually, this doesn't do quite what I thought it would.
What's the advantage of rendering it outside of the hierarchy?
Ronn
@ronnross
May 31 2018 20:08
I don't think there is an advantage. I just was unable to get it to work by using a ref
so I gave this a try and it worked.
Douglas Russell
@dpwrussell
May 31 2018 20:12
We have a component with a render method with a div the same as any other React component. Then in componentDidMount we initialise it.
When React state needs to update the component is the tricky bit. Basically on this boundary we calculate what changes should be made and then call whatever javascript methods we need to on OSD to effect change.
Ronn
@ronnross
May 31 2018 20:25
hmmm. So you didn't need a ref?
I might give that a try, could be simpler than what I have done.
Douglas Russell
@dpwrussell
May 31 2018 20:27
Obviously you have to be careful as you don't want to be mounting and unmounting this component very much.