Gatsby 更新url查询时,页面道具不会更新

Gatsby 更新url查询时,页面道具不会更新,gatsby,Gatsby,我使用的是盖茨比1.4.0 我想在一个网站上有多个按钮,链接到同一页,但不同的搜索查询。例如,虚拟页面中有两个按钮: Link A -> Routes to '/test/?name=john Link B -> Routes to '/test/?name=peter 我想使用from'gatsby link'将用户路由到新路径,这样页面就不会刷新 问题 导航时,我的布局文件会按预期重新呈现,但我的页面文件不会重新呈现。只有重新加载页面时,正确的查询才会传递到页面文件 layou

我使用的是盖茨比1.4.0

我想在一个网站上有多个按钮,链接到同一页,但不同的搜索查询。例如,虚拟页面中有两个按钮:

Link A -> Routes to '/test/?name=john
Link B -> Routes to '/test/?name=peter
我想使用from'gatsby link'将用户路由到新路径,这样页面就不会刷新

问题

导航时,我的布局文件会按预期重新呈现,但我的页面文件不会重新呈现。只有重新加载页面时,正确的查询才会传递到页面文件

layout/index.js文件(简化):

render() {
    console.log(this.props.location.search) // Correct query every time navigation occurs
    return (
      <div>
        {this.props.children()}
        <Footer />
      </div>
    )
  },
render(){
console.log(this.props.location.search)//每次导航时都正确查询
返回(
{this.props.children()}
)
},
页面/test.js

import React from 'react'
import Link from 'gatsby-link'

export default class Dummy extends React.Component {

  render() {
    console.log(this.props.location.search) // Does not re-render on navigation.

    return (
      <div>
        <Link to="/test/?name=john">John</Link>
        <Link to="/test/?name=peter">Peter</Link>
      </div>
    )
  }
}
从“React”导入React
从“盖茨比链接”导入链接
导出默认类Dummy扩展React.Component{
render(){
console.log(this.props.location.search)//在导航时不会重新呈现。
返回(
约翰
彼得
)
}
}


有没有办法在更新查询时强制重新呈现页面

跳过链接中的最后一个/是可行的,因此:

<Link to="/test?name=john">John</Link>
<Link to="/test?name=peter">Peter</Link>
约翰 彼得