I am new and developing simple dashboard in react js.
My App.js file is
<BrowserRouter>
<div>
<div>
<Switch>
<Route exact path="/" component={Login} />
<PublicRoute path="/login" component={Login} />
<PrivateRoute path="/dashboard" component={Home} />
<PrivateRoute path="/home2" component={Home2} />
</Switch>
</div>
</div>
</BrowserRouter>
There are map function in Home component which is call another component named Deposits.js for mapping array elements on card component.
Home.js file code part is:
<Grid container spacing={3}>
{menuData.map((x) => (
<Grid item xs={12} md={4} lg={3}>
<Paper>
<Deposits site_informations={x} channelName_coverted
{(x.ChannelName).replace("_"," ")} />
</Paper>
</Grid>
In Deposits.js there is a button, I want to push another page with this button click actually.
<IconButton onClick={() => props.history.push({ pathname: "/home2", state: { number: site_info.channel } })} >
<TrendingUp />
</IconButton>
But when onClick, cannot read property 'push' of undefined error is coming. What should I do ?