相关疑难解决方法(0)

React.js - 在重新渲染时输入失去焦点

我只是写文本输入和onChange我调用的事件setState,所以React重新呈现我的UI.问题是文本输入总是失去焦点,所以我需要再次关注每个字母:D.

var EditorContainer = React.createClass({

    componentDidMount: function () {
        $(this.getDOMNode()).slimScroll({height: this.props.height, distance: '4px', size: '8px'});
    },

    componentDidUpdate: function () {
        console.log("zde");
        $(this.getDOMNode()).slimScroll({destroy: true}).slimScroll({height: 'auto', distance: '4px', size: '8px'});
    },

    changeSelectedComponentName: function (e) {
        //this.props.editor.selectedComponent.name = $(e.target).val();
        this.props.editor.forceUpdate();
    },

    render: function () {

        var style = {
            height: this.props.height + 'px'
        };
        return (
            <div className="container" style={style}>
                <div className="row">
                    <div className="col-xs-6">
                    {this.props.selected ? <h3>{this.props.selected.name}</h3> : ''}
                    {this.props.selected ? <input type="text" value={this.props.selected.name} onChange={this.changeSelectedComponentName} /> : ''}
                    </div>
                    <div …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs

76
推荐指数
9
解决办法
4万
查看次数

标签 统计

javascript ×1

reactjs ×1