我正在使用react + redux和react-bootstrap组件。 我想将FormControl文本元素(email)的值传递给调度的redux操作,但我不知道该怎么做。
class LoginForm extends React.Component {
render() {
const email = React.findDOMNode(this.refs.email);
return (
<div>
<Form horizontal>
<FormGroup controlId="formHorizontalEmail">
<Col componentClass={ControlLabel}>Email</Col>
<Col><FormControl type="email" ref="email"/></Col>
</FormGroup>
<FormGroup>
<Col>
<Button type="submit" block>Sign in</Button>
</Col>
</FormGroup>
</Form>
<Button onClick={() => this.props.doLogin(email, 'password')}>Login</Button>
</div>
)
}
}
/**
* Connect staff.
*/
const mapStateToProps = (state) => {
return {
...
};
};
const mapDispatchToProps = (dispatch) => {
return {
doLogin: (email, password) => dispatch(performLogin(email, password))
};
};
export default connect(mapStateToProps, mapDispatchToProps)(LoginForm)
答案 0 :(得分:3)
如何使用React读取FormControl的文本值(根据我的研究)的唯一方法是:
double[] weights = new double[count];
for( int j = 0; j < count; j++ )
{
weights[j] = rand.NextDouble();
}