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

Accept iterables and collections as children. #31

Open
rodogir opened this issue Apr 16, 2018 · 1 comment
Open

Accept iterables and collections as children. #31

rodogir opened this issue Apr 16, 2018 · 1 comment

Comments

@rodogir
Copy link

rodogir commented Apr 16, 2018

React supports rendering of iterables and collections as childrens. react-tree-walker does not support this at this moment leading to unexpected results when using Iterables (e.g. List from immutable-js) as children. Subtrees that are rendered in react are might be skipped by the visitor.

I created a minimal example that shows the issue: https://codesandbox.io/s/o9kzlrql86

Here are some links from the original react discussion:
Original Issue
Original PR

Would be great to have this feature!

@jaredLunde
Copy link

I've accomplished this in a fork using code lifted from the React merge that allowed for iterator functions:
https://codesandbox.io/s/pj998lr3lj

Relevant lines:
https://github.com/jaredLunde/react-tree-walker/blob/master/src/index.js#L15
https://github.com/jaredLunde/react-tree-walker/blob/master/src/index.js#L78
https://github.com/jaredLunde/react-tree-walker/blob/master/src/index.js#L137
https://github.com/jaredLunde/react-tree-walker/blob/master/src/index.js#L259

Would you accept a PR w/ test that clears this issue @ctrlplusb? My version of the library is quite a bit different at this point (removed Preact stuff, breadth-first resolve rather than depth-first to allow for concurrency, added more strict element type checks etc), but I can try to make a PR as simple as possible for you.

Otherwise you can obviously just lift those sections on your own.

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

2 participants