react-bootstrap设置FormControl的值

时间:2017-03-01 13:28:20

标签: javascript reactjs react-bootstrap

当我尝试使用React-Bootstrap设置FormControl的值时,我在控制台中遇到错误。

invariant.js:44 Uncaught Error: Objects are not valid as a React child (found: [object HTMLTextAreaElement]). If you meant to render a collection of children, use an array instead or wrap the object using createFragment(object) from the React add-ons. Check the render method of `FormGroup`.

FormControl没有价值方法,因此不确定如何实现这一目标。这就是我试图设置值的方式。

<FormGroup controlId="parameterDescription">
    <ControlLabel>Description</ControlLabel>
    <FormControl componentClass="textarea" placeholder="Description of parameter function" inputRef={(ref) => {this.state.description = ref}} readOnly={true}>
        {this.state.description}
    </FormControl>
</FormGroup>

1 个答案:

答案 0 :(得分:6)

这是对的:

<FormControl value={someText}/>