1 回答
TA贡献1789条经验 获得超8个赞
您需要利用 重定向到新页面,并且需要呈现组件才能有效,并且 onClick 处理程序不会呈现返回的值history.pushRedirect
<Button
variant="contained"
color="primary"
className={classes.button}
endIcon={<SendIcon/>}
onClick={() => {
props.history.push({
pathname: '/view',
state: {
id: row.id
}
});
}
>
View History
</Button>
使用方式和Redirect would be to setStaterender the component conditionally
<Button
variant="contained"
color="primary"
className={classes.button}
endIcon={<SendIcon/>}
onClick={() => {
this.setState({ redirectWithState: {
id: row.id
}})
>
View History
</Button>
{ redirectWithState && <Redirect
to={{
pathname: '/view',
state: redirectWithState
}}
/>
}}
添加回答
举报