首页 > 解决方案 > 盖茨比中 this.props.history.push 的等价物是什么?

问题描述

我正在尝试做this.props.history.push("/payment/" + stripe_plan_id)

Gastby 中 this.props.history.push 的等价物是什么?

我得到错误TypeError: Cannot read property 'push' of undefined

标签: reactjsgatsby

解决方案


最佳答案不再起作用但这确实有效:

import { navigate } from "gatsby"  
navigate(`/payment/${stripe_plan_id.id}`)

推荐阅读