hygiene: {
toiletries: {
question:
'Do you need help buying toiletries like soap and shampoo?',
agree: false
},
washing: {
question: 'Do you need help washing your hair and body?',
agree: false
},
laundry: {
question:
'Do you need help doing your laundry and cleaning your clothes?',
agree: false
},
more: ''
},
toilet: {
access: {
question: 'Do you need help to access the toilet?',
agree: false
},
toiletUse: {
question: 'Do you need help to use the toilet?',
agree: false
},
nightAccess: {
question: 'Do you need help to go to the toilet at night',
agree: false
},
more: ''
},
//Use spread to open up the object in state to setState
handleChangeInput = (event, qs, section) => {
const target = event.target;
// console.log("target", target)
const value = target.name === 'more' ? target.value : null;
console.log("value", value)
this.setState({
[section]: {
...this.state[section],
[qs]: { ...this.state[section][qs], more: value }
}
});
};
# Routing pages
// Use section to name the index of the object in state (above)
<Route
path="/toilet"
render={props => (
<Toilet
info={this.state.toilet}
section="toilet"
handleChangeInput={this.handleChangeInput}
toggleChange={this.toggleChange}
/>
)}
/>