我正在建立一个nextjs博客应用程序。在当前的博客布局中,我设法使用useEffect/fetch在我的侧边栏上获取数据(我需要它来显示我的“最近发表的文章”)(因为getInitialProps只在页面下工作),但每当我在页面之间路由时,它就会触发。我使用了"[]“方法,但仍然没有成功: const [posts, s
我希望每次路由改变时console.log('Refresh')都会运行(从Component1切换到Component2)。但只有在第一次渲染时才会触发。为什么?ReactDOM.render(<BrowserRouter><App /></BrowserRouter>, document.getElementById('root'));import Rea