我正在尝试在执行 handleNext() 之前向 TextField 和 Select 添加验证。这是代码(2 个组件):
class Quote extends React.Component {
state = {
activeStep: 0,
zipCode: '',
destination: '',
sedanPrice: '',
suvPrice: '',
labelWidth: 0,
};
getStepContent = (step) => {
switch (step) {
case 0:
return (
<div>
<QuoteForm
{...this.state}
{...this.state.value}
handleChange={this.handleChange}
/>
</div>
)
case 1:
return (
<div>
<QuotePrice
{...this.state}
{...this.state.value}
/>
</div>
)
default:
throw new Error('Unknown step');
}
}
handleNext = () => {
this.setState(prevState => ({
activeStep: prevState.activeStep + 1,
})); …Run Code Online (Sandbox Code Playgroud) validation reactjs material-ui react-material-ui-form-validator