在没有 React 的普通旧语义 UI 中,我已经能够在模态中放置一个表单而没有任何问题。
使用 Semantic-UI + React 版本,我能够在模态内显示表单,但它并没有像我期望的那样工作。
例如,在模态显示之后,模态内的表单也被显示。如果我开始在输入字段中输入,则会显示此错误:
Error: Invariant Violation: findComponentRoot(..., .1.1.1.0.4.0.0.1): Unable to find element. This probably means the DOM was unexpectedly mutated (e.g., by the browser), usually due to forgetting a <tbody> when using tables, nesting tags like <form>, <p>, or <a>, or using non-SVG elements in an <svg> parent. Try inspecting the child nodes of the element with React ID ``.
由于这个错误,我使用输入的其他react代码无法按预期工作。
这是演示问题的代码的最简单版本:
ConfirmEdit = React.createClass({
    render(){
        return (
            <div className="ui modal editform">
                <form className="ui form">
                    <div className="field">
                        <label>Name</label>
                        <input name="name" type="text" placeholder="Name">
                        </input>
                    </div>
                </form>
            </div>
        );
    }
});
在我添加上面的组件的组件中,我确保触发它:
$('.ui.modal.editform').modal('show');
正如刚才提到的。它显示正常,但由于不变量违反而无法正常工作。
我如何解决这个问题并让它发挥作用?