shirakaba / react-nativescript

React renderer for NativeScript
https://react-nativescript.netlify.com
MIT License
280 stars 14 forks source link

Should use ProxyViewContainer for list cells #3

Closed shirakaba closed 5 years ago

shirakaba commented 5 years ago

More lightweight than a ContentView.

https://github.com/NativeScript/NativeScript/blob/master/tns-core-modules/ui/proxy-view-container/proxy-view-container.ts

shirakaba commented 5 years ago

Tried this; but a ProxyViewContainer doesn't remain in the view hierarchy; it dissolves and spreads out its contents just like a HTML DOM Fragment, leaving its contents to receive the ProxyViewContainer's parent as their immediate parent instead. In this case, I tried rendering the List Portals into the StackLayout child that I have (traditionally) given it.

I should note that on initial mount, all the Portals did happily render when a ProxyViewContainer was used as their host handle! However, as I'll describe hereon in, the host view recycling prevented any further progress; use of ProxyViewContainers caused us to lose our reference to .

In this case, the ProxyViewContainer's parent (and thus, the host instance) was determined to be the StackLayout that I rendered the Portals as children of. We lost our reference to the physical table cell view container, and thus could not re-reconcile it with React. The log message indicating this:

Unable to find 'nativeCell' that args.view corresponds to!

(Where args.view was found to be the StackLayout).

I then kept a React ref to the StackLayout and tried rendering everything into that. However, it complained:

JS ERROR Error: onMeasure() did not set the measured dimension by calling setMeasuredDimension() Label(9)

I also tried swapping that StackLayout for a ContentView, but it gave exactly the same error.

Next, I passed a React ref to the ListView itself and tried rendering everything directly into that instead. However, this was no good, either:

JS ERROR TypeError: parent._removeContainer is not a function. (In 'parent._removeContainer(this)', 'parent._removeContainer' is undefined)

I think these errors stem from the fact that those views are not actually the direct parents of the Portals in the host view hierarchy. It does look like StackLayout and ContentView 'get further', but I think the error message still indicates deep unhealthiness.

... So for now, as much as I'd love to remove one container view for every cell rendered, I don't see this being a trivial thing to implement.

shirakaba commented 5 years ago

May try comparing to PlaceHolderView (not totally sure what it is) in future.