使用react-bootstrap反应+还原反应> FormControl>获得价值

时间:2016-12-08 00:10:11

标签: reactjs redux react-bootstrap form-control

我正在使用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)

1 个答案:

答案 0 :(得分:3)

如何使用React读取FormControl的文本值(根据我的研究)的唯一方法是:

double[] weights = new double[count];
for( int j = 0; j < count; j++ )
{
     weights[j] = rand.NextDouble();
}