Lucifier129 / react-lite

An implementation of React v15.x that optimizes for small script size
MIT License
1.73k stars 98 forks source link

vchild.initTree is undefined #16

Closed fritx closed 8 years ago

fritx commented 8 years ago

image

It breaks when an Object appears

// src/virtual-dom.js
    initTree: function initTree(parentNode) {
        var type = this.type;
        var props = this.props;

        var node = this.node = createElement$1(type, props);
        this.eachChildren(function (vchild) {

            console.log(vchild)   // added
            vchild.initTree(node);
        });
        appendNode(parentNode, node);
        this.attachRef();
    },
fritx commented 8 years ago

image

Lucifier129 commented 8 years ago

why the children list have an object which is not vaild(react elementreact componentstring)

fritx commented 8 years ago

@Lucifier129 oh that's an Immutable object written by my partner. I fixed it when I changed {list.map(xxxx)} to {list.map(xxxx).toJS()}. In react, it works without the fix. Maybe react would call it automatically? I'm not sure. Maybe react-lite can also do it for us! Btw, awesome work on react-lite!

Lucifier129 commented 8 years ago

@fritx thank you.

react-lite has no plan to support that tansformImmutable object to native data structure as automatic, such as I think React.createClass with autobind has bad smell, it's hard to distinguish native data/immutable data and autobind method/normal method

sorry about that.

fritx commented 8 years ago

No problem! I'm closing this as it is fixed ;)