Architecture: render tree presentation #972
Replies: 1 comment
-
| 
         I agree that we probably hit the limitations of  Another thing to keep in mind is that we don't handle native components (List, inputs, etc.). Even though I'm not sure that'd be a problem with any of the discussed implementations, we need to make sure that at least the implementation is the same as before (for instance, being able to trigger  Regarding the difference between the 2nd and 3rd solution, I guess the main question is what will we miss with it? What is the drawback?  | 
  
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a rather long-term architectural discussion, and changing any of this stuff would probably break a lot of user code.
In the current codebase we rely heavily on
ReactTestInstanceas our representation of component tree node. While it seems it has been created to facilitate testing by providingfind/findAllmethods, there are certain limitations to it:View,Text, etc) and composite components (class or function, framework or user-defined) which forces us to filter composite components in test and also prevents easy user access to traversing only-host componentsfireEventReact Test Renderer provides two alternatives representations of component tree, namely
ReactTestRendererJSONreturned bytoJSON()method and relatedReactTestRendererTreereturned bytoTree()method. These methods are only exposed onReactTestRenderercreatemethod output, so there is no easy transition betweenReactTestInstanceandReactTestRendererJSON/Tree.ReactTestRendererJSON/Treehave certain benefits:ReactTestRendererJSONseems to expose only host componentsprops,childrenandrenderedfieldsWhile they also have their drawbacks:
findAllmethod - but that should be relatively easy to reimplementparentfield for upward tree navigationIf we were to open this can of architectural worms and revisit our existing architectural assumptions we have broadly three options:
ReactTestInstancebased codeReactTestRendererJSON/TreeReactTestRendererJSONwould be the best candidate).Options 3 is the most complex to build but could potentially allow us to encapsulate a lot of RN runtime env simulation code inside, building a sort of mini
JS Domenvironment. Probably some POC would be necessary to research benefits and limitations of such solution.@thymikee @AugustinLF @pierrezimmermannbam wdyt?
Beta Was this translation helpful? Give feedback.
All reactions