下拉字段已重置,但输入字段不在React TypeScript中

时间:2020-03-09 12:44:36

标签: reactjs typescript react-redux

当我单击重置按钮时,下拉字段已重置,但输入字段未重置。

单击重置按钮时,我已将状态设置为空。

    const newDeviceForm = {
        meterName: " ",
        manufacturerId: 0,
        hostName: " ",
        port: " ",
        protocol: "TCP",
        authType: null,
        passowrd: " ",
        conProtocol: "DLMS",
        securityType: null,
        systemTitle: " ",
        blockCipherKey: " ",
        authenticationKey: "" ,
        userId: " ",
        tenantId: 0,
        referencingName: null
        ,phase:0
    };
   const handleReset = (e) => {
        setDevice(newDeviceForm);
        setSumbmited(false);
        setShowMessage(false);
    }

    return (

                    <div className="p-col-12 p-md-4" style={{ textAlign: 'center' }}>
                        <Button
                            label="Save"
                            onClick={handleSubmit}
                            type="button"
                            className="p-button-raised"
                            style={{  marginBottom: '10px' }}
                        />
                    </div>
                </div>
            </div>
        </div>
    );
};
const mapStateToProps = (state: any) => {
    const { deviceFormData } = state;
    return {
        deviceFormData
    };
};
export default connect(mapStateToProps)(NewDevice);

这是我的重置页面:

enter image description here

0 个答案:

没有答案