Я нашел решение простое решение сам.Я отправляю свою функцию для компонента Categories, и когда Component didMounting или willUnmounts я отправляю Boolean, что случилось.
Примерно так: Categories.js
componentDidMount = () => {
console.log('CREATED');
this.props.showFull(false);
};
componentWillUnmount = () => {
this.props.showFull(true);
}
Main.js
constructor(props) {
super(props);
this.state = {
direction: 'row',
justify: 'flex-start',
alignItems: 'stretch',
hidden: true
}
}
updateState = (ok) => {
this.setState({
hidden: ok,
});
console.log('updated ' + ' ' + ok);
}
return (
<div className={classes.root}>
<Grid container className={classes.root}>
<Grid
container
spacing={16}
className={classes.demo}
alignItems={this.state.alignItems}
direction={this.state.direction}
justify={this.state.justify}
>
<Hidden xsDown>
<Grid
item
lg={2}
md={4}
style={{
width: '100%',
maxWidth: 280,
minWidth: 0,
position: 'fixed',
height: '100%',
zIndex: 1,
}}>
<Categories showFull={this.updateState} />
</Grid>
</Hidden>
<Grid container item lg={12} md={12} spacing={16}
style={{paddingLeft: this.state.hidden ? 0 : 300, zIndex: 3}}
>
{news}
</Grid>
</Grid>
</Grid>
</div>
);