【问题标题】:using Link in react does not re-render the component在 react 中使用 Link 不会重新渲染组件
【发布时间】:2018-07-04 16:10:22
【问题描述】:

我在路由“http://localhost:3000/detail/machine-learning-654a79f32638a8b300f9b92aae0f4a17”,点击此页面上的某个链接后,它会使用“react-router-dom”中的“链接”将我重定向到页面“http://localhost:3000/detail/upsc-detail-654a79f32638a8b300f9b92aae0f4a17”,但它不会重新渲染该组件并在该页面上显示相同的内容。

【问题讨论】:

    标签: reactjs


    【解决方案1】:

    确保您在组件更新时更新了您的状态。通常使用 componentDidUpdate 和 render 函数完成

    【讨论】:

    • 谢谢,我忘了在 componentDidUpdate() 方法中重置一些状态变量。
    猜你喜欢
    • 2023-03-13
    • 1970-01-01
    • 2023-03-28
    • 1970-01-01
    • 2022-11-29
    • 2020-02-18
    • 2016-06-07
    • 2021-06-07
    • 1970-01-01
    相关资源
    最近更新 更多