Reactjs渲染未被调用的子节点的方法

时间:2016-04-26 12:24:33

标签: javascript reactjs ecmascript-6

render : function () {
        var childNode = "";
        if(this._shouldShow()) {
            childNode = React.createElement(window[this.state.data.type], {
                id : this.state.data.type + "-" + this.props.id,
                data : this.state.data,
                ref : this.state.level,
                setNextLabel : this._setNextLabel,
                setPreviousLabel : this._setPreviousLabel,
                disableMove : this._disableMove,
                enableMove : this._enableMove,
                loadWizard : this._loadWizard
            });
        }
        return (
            <div id={"box-" + this.state.id} className="modal wizard" role="dialog" tabIndex="-1">
                <div className="modal-dialog modal-lg">
                    <div className="modal-content">
                        <div className="modal-header">
                            <button
                                type="button"
                                className="close"
                                data-dismiss="modal"
                                aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                            <h3>{this.props.title}</h3>
                        </div>
                        <div className="modal-body">
                            {(!this.state.status) ? "" : (
                                <div style={{padding: '10px',
                                    margin: '-15px',
                                    marginBottom: '15px',
                                    background: '#DC0000',
                                    color: '#FFF'}}>
                                    {this.state.statusMessage}
                                </div>
                            )}
                            {childNode} //this component is getting mounted but its render is not getting called 
                        </div>

                    </div>
                </div>
            </div>
        );
    }

JS控制台中没有错误/异常。不知道为什么甚至没有调用render方法?请为此快速转身。在childnode的componentDidMount方法中添加了日志并成功记录。如果我尝试在render方法中记录某些东西,它甚至都没有记录。

0 个答案:

没有答案