I need a way to toggle 'flex' to 'none' and vice versa for the following:
const UpdateSampleStyle = makeStyles((theme) => ({
gridcontainer: {
display: 'none', //props => props.show,
justifyContent:'center',
marginTop:'5px'
},
}));
function UpdateFieldObservations({formdata, handleChangeParent}){
const show = 'flex';
const classes = UpdateSampleStyle(show);
const [displaySettings, setDisplaySettings] = useState({
tradeWaterGrabSample: {display:'flex', justifyContent:'center', marginTop:'5px'},
tradeWaterCompositeProgram: {display:'flex', justifyContent:'center', marginTop:'5px'},
soilVapourGrabSample: {display:'flex', justifyContent:'center', marginTop:'5px'},
soilVapourInsituMeter: {display:'flex', justifyContent:'center', marginTop:'5px'},
stackEmissionGrabSample: {display:'flex', justifyContent:'center', marginTop:'5px'},
stackEmissionInsituMeter: {display:'flex', justifyContent:'center', marginTop:'5px'},
dustDeposition: {display:'none', justifyContent:'center', marginTop:'5px'}
});
}
It is used as follows:
<Grid container spacing={3} style={displaySettings.tradeWaterGrabSample}>
</Grid>
<Grid container spacing={3} style={displaySettings.tradeWaterCompositeProgram}>
</Grid>
<Grid container spacing={3} style={displaySettings.soilVapourGrabSample}>
</Grid>
and so on..
Update: So there were tiny mistakes in my code after I implemented the solution here...that can go unnoticed, adding here for anyone facing the same:
const classes = UpdateSampleStyle(show);
changed to
const classes = UpdateSampleStyle({show});
classname changed to className