0
我定義形式作出反應以引導和終極版用下面的代碼不工作:陣營+引導+ Redux的價值形式
import React from 'react';
import { FormGroup, ControlLabel, FormControl, HelpBlock, Button } from 'react-bootstrap';
import { connect } from 'react-redux';
import './actions';
const _c = component => connect(s => s)(component);
const FieldGroup = ({ id, label, help, ...props }) => {
return (
<FormGroup controlId={id}>
<ControlLabel>{label}</ControlLabel>
<FormControl {...props} />
{help && <HelpBlock>{help}</HelpBlock>}
</FormGroup>
);
};
const LoginForm = _c(React.createClass({
render() {
return (
<form>
<FieldGroup
id="loginText"
type="text"
label="Text"
placeholder="Email"
value={this.props.user.email ? this.props.user.email[0] : ''}
/>
<FieldGroup
id="loginPassword"
label="Password"
type="password"
/>
<Button bsStyle="primary" bsSize="large">Login</Button>
</form>
);
}
}));
這工作,和值出現在「用戶名」欄,但它不可編輯。我試圖更改value={this.props.user.email ? this.props.user.email[0] : ''}
到defaultValue={this.props.user.email ? this.props.user.email[0] : ''}
,這使得它可編輯,但默認值從不出現。我究竟做錯了什麼?