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.
-
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
ReactTestInstance
as our representation of component tree node. While it seems it has been created to facilitate testing by providingfind
/findAll
methods, 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 componentsfireEvent
React Test Renderer provides two alternatives representations of component tree, namely
ReactTestRendererJSON
returned bytoJSON()
method and relatedReactTestRendererTree
returned bytoTree()
method. These methods are only exposed onReactTestRenderer
create
method output, so there is no easy transition betweenReactTestInstance
andReactTestRendererJSON/Tree
.ReactTestRendererJSON/Tree
have certain benefits:ReactTestRendererJSON
seems to expose only host componentsprops
,children
andrendered
fieldsWhile they also have their drawbacks:
findAll
method - but that should be relatively easy to reimplementparent
field for upward tree navigationIf we were to open this can of architectural worms and revisit our existing architectural assumptions we have broadly three options:
ReactTestInstance
based codeReactTestRendererJSON/Tree
ReactTestRendererJSON
would 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 Dom
environment. 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