Я пытаюсь сбросить значения при изменении значения зависимости на SelectInput.Но это, конечно, зациклить и сломать страницу.Здесь найдите код, который я сделал до сих пор.
Как можно опустить это в моем коде.
import {
SelectInput,
required
} from 'react-admin';
import data from '../data';
import { withStyles } from '@material-ui/core/styles';
import React, { Component } from 'react';
import { DependentInput } from 'aor-dependent-input';
const initialState = {
way_of_join: data.way_of_join
};
class WayOfJoinSelectInput extends Component {
constructor(props) {
super(props)
this.state = initialState;
}
reset(){
this.setState({initialState});
}
switchSector = (props) => {
if (props !== undefined && Object.keys(props).length > 0) {
var value = props.General_Service.service_sector;
this.reset();
switch (value) {
case 'sleas':
this.state.way_of_join.splice(4, 3)
break;
case 'sltes':
this.state.way_of_join.splice(2, 1)
break;
}
}
};
render() {
return (
<DependentInput resolve={this.switchSector}>
<SelectInput
source="General_Service.way_join"
label="Way of Join"
validate={required()}
// onChange={this.reset()}
choices={this.state.way_of_join}
/>
</DependentInput>
)
}
}
export default withStyles(styles)(WayOfJoinSelectInput);
Здесь найти, что происходит при ошибке.