那就是我得到的错误:
未能编译./node_modules/@material-ui/core/Modal/Modal.js找不到模块:
无法解析'@ babel / runtime / helpers / builtin / assertThisInitialized'
在
'C:\ Users \ rifat \ Desktop \ waves \ client \ node_modules @ material-ui \ core \ Modal'
此错误在构建期间发生,无法消除。
那是node_modules文件夹:
看来路径是正确的,所以为什么要反应抱怨。
那是我的文件:
import React, { Component } from 'react';
import FormField from '../utils/Form/formfield';
import { update, generateData, isFormValid } from
'../utils/Form/formActions';
import Dialog from '@material-ui/core/Dialog';
import { connect } from 'react-redux';
import { registerUser } from '../../actions/user_actions';
class Register extends Component {
state = {
formError: false,
formSuccess: false,
formdata: {
name: {
element: 'input',
value: '',
config: {
name: 'name_input',
type: 'text',
placeholder: 'Enter your name'
},
validation: {
required: true
},
valid: false,
touched: false,
validationMessage: ''
},
lastname: {
element: 'input',
value: '',
config: {
name: 'lastname_input',
type: 'text',
placeholder: 'Enter your lastname'
},
validation: {
required: true
},
valid: false,
touched: false,
validationMessage: ''
},
email: {
element: 'input',
value: '',
config: {
name: 'email_input',
type: 'email',
placeholder: 'Enter your email'
},
validation: {
required: true,
email: true
},
valid: false,
touched: false,
validationMessage: ''
},
password: {
element: 'input',
value: '',
config: {
name: 'password_input',
type: 'password',
placeholder: 'Enter your password'
},
validation: {
required: true
},
valid: false,
touched: false,
validationMessage: ''
},
confirmPassword: {
element: 'input',
value: '',
config: {
name: 'confirm_password_input',
type: 'password',
placeholder: 'Confirm your password'
},
validation: {
required: true,
confirm: 'password'
},
valid: false,
touched: false,
validationMessage: ''
}
}
}
updateForm = (element) => {
const newFormdata = update(element, this.state.formdata, 'register');
this.setState({
formError: false,
formdata: newFormdata
})
}
submitForm = (event) => {
event.preventDefault();
let dataToSubmit = generateData(this.state.formdata, 'register');
let formIsValid = isFormValid(this.state.formdata, 'register');
if(formIsValid) {
this.props.dispatch(registerUser(dataToSubmit))
.then(response => {
if(response.payload.success) {
this.setState({
formError: false,
formSuccess: true
});
setTimeout(() => {
this.props.history.push('/register_login');
}, 3000)
} else {
this.setState({ formError: true });
}
}).catch(e => {
this.setState({ formError: true });
});
} else {
this.setState({
formError: true
});
}
}
render() {
return (
<div className="page_wrapper">
<div className="container">
<div className="register_login_container">
<div className="left">
<form onSubmit={(event) => this.submitEvent(event)}>
<h2>Personal information</h2>
<div className="form_block_two">
<div className="block">
<FormField
id={'name'}
formdata={this.state.formdata.name}
change={(element) => this.updateForm(element)}
/>
</div>
<div className="block">
<FormField
id={'lastname'}
formdata={this.state.formdata.lastname}
change={(element) => this.updateForm(element)}
/>
</div>
</div>
<div>
<FormField
id={'email'}
formdata={this.state.formdata.email}
change={(element) => this.updateForm(element)}
/>
</div>
<h2>Verify password</h2>
<div className="form_block_two">
<div className="block">
<FormField
id={'password'}
formdata={this.state.formdata.password}
change={(element) => this.updateForm(element)}
/>
</div>
<div className="block">
<FormField
id={'confirmPassword'}
formdata={this.state.formdata.confirmPassword}
change={(element) => this.updateForm(element)}
/>
</div>
</div>
<div>
{ this.state.formError ?
<div className="error_label">
Please check your data
</div>
:null}
<button onClick={(event) => this.submitForm(event)}>
Create an account
</button>
</div>
</form>
</div>
</div>
</div>
<Dialog open={this.state.formSuccess}>
<div className="dialog_alert">
<div>
Congratulations!
</div>
<div>
You will be redirected to the login in a couple of seconds...
</div>
</div>
</Dialog>
</div>
);
}
}
export default connect()(Register);
希望我分享的内容能对您有所帮助,以防万一,我将为您提供尽可能多的信息,以帮助我解决问题。
提前致谢!
最佳答案
我重新安装了Material UI,然后重新启动了服务器,一切再次正常。