I have 3 components/pages Home, page1, page2 and I'm sending props from home and calling page1
<Link
style={{ textDecoration: "none", color: "inherit" }}
to={{
pathname: "/page1",
Props: { categoryID: val.id, categoryName: val.name }
}}
/>;
Then page 1 is getting these props in the constructor and defining states
class BuyerItems extends Component{
constructor(props) {
super(props);
this.state = {
id: props.location.aboutProps.categoryID,
name: props.location.aboutProps.categoryName,
gigs:[],
}
this.getGigs();
}
Now from here if I go to page2 through link and then press browser back button it gives following error
TypeError: Cannot read property 'categoryID' of undefined
How to get these props or states from history and where to write that code?