react-tree-walker icon indicating copy to clipboard operation
react-tree-walker copied to clipboard

Accept iterables and collections as children.

Open rodogir opened this issue 6 years ago • 1 comments

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!

rodogir avatar Apr 16 '18 17:04 rodogir

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.

jaredLunde avatar Sep 19 '18 16:09 jaredLunde