Skip to content

Accept iterables and collections as children. #31

Open

Description

@rodogir

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!

Activity

  1. jaredLunde commented on Sep 19, 2018

    @jaredLunde

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions