<Input type="checkbox" checked={this.state.isCheckedOther} label="Other"
onChange={ (isCheckedOther)=> {
this.setState({ isCheckedOther: !this.state.isCheckedOther });
if(isCheckedOther===true){
this.setState({ eng_oneoff_other: 7 });
this.setState({ openPatientSupportOther: !this.state.openPatientSupportOther });
}else {
this.setState({ eng_oneoff_other: '' });
this.setState({ openPatientSupportOther: !this.state.openPatientSupportOther });
}
}}
readOnly />
class GridView extends Component {
constructor(...args) {
super(...args);
this.state = {
form: ''//<UserHome {...this.props} change={this.changeView}/>
};
//this.change = this.change.bind(this)
//this.changeView = this.changeView.bind(this)
}
render() {
var changeView= () => this.setState({form: <NewPatient />});
this.state = {
form: <UserHome change={changeView}/>
};
return (
{this.state.form}
<Button onClick={changeView}/>
<Button onClick={this.props.change}
class GridView extends Component {
constructor(...args) {
super(...args);
this.state = {
form: <UserHome change={this.changeView}/>
};
this.change = this.change.bind(this)
}
changeView() {
this.setState({form: <NewPatient />})
}
change(){
this.setState({ open: !this.state.open })
}
render() {
return (
{this.state.form }
и в самом элементе выдает ошибку TypeError: Cannot read property 'setState' of nullможет нужно как то this указать или еще что то?
class GridView extends Component {
constructor(...args) {
super(...args);
this.state = {
form: <UserHome {...this.props}/>
};
this.change = this.change.bind(this)
}
changeView(){
this.setState({ form: <NewPatient /> })
}
...{this.state.form}
onClick={changeView()}
Спасибо