Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get object tree presentation of components tree before initial render? #3244

Closed
roman01la opened this issue Feb 23, 2015 · 8 comments
Closed

Comments

@roman01la
Copy link
Contributor

One way I've found is to apply a mixin to every component which takes _rootNodeID, treat it as path and construct an object. But _rootNodeID includes ids not only of React components, but elements as well.

@syranide
Copy link
Contributor

Why do you need this?

@roman01la
Copy link
Contributor Author

I'm experimenting with a concept of global state object, where it should be programmatically constructed to represent hierarchy of components tree. Thus it's easier to pass state as props from root component down the tree.

@sophiebits
Copy link
Collaborator

Not sure what you mean. Can you give a code example of the problem you're trying to solve?

@iamdustan
Copy link
Contributor

Related, is there a way to traverse the render tree before rendering?
E.g. how does GraphQL work? https://twitter.com/iamdustan/status/571328094398779395

Does it do ahead of time tree traversal pulling the statics: {queries: {}} calls out or use a mixin for every component with graphql calls?

@roman01la
Copy link
Contributor Author

@iamdustan yeah, this is somewhat my question.
@spicyj Ok, check this thread, the idea is to use a hierarchical object that mirrors components tree of the app.

@gaearon
Copy link
Collaborator

gaearon commented Oct 27, 2016

Closing as the tree is considered an implementation detail.

@gaearon gaearon closed this as completed Oct 27, 2016
@reverofevil
Copy link

@gaearon Is it possible to have React without a component tree? Could you reconsider, please?

Public API for a component tree traversal would allow writing (de)serializers to rehydrate without resorting to a global state.

@gaearon
Copy link
Collaborator

gaearon commented Dec 16, 2016

We’re aware of use cases—please see #4595 for a place to discuss this.

Right now we’re in the middle of a React rewrite (https://www.youtube.com/watch?v=aV1271hd9ew) so it's not a very good time for us to expose any internals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants