acdlite / acdlite/redux-router

TypeError: Cannot read property 'location' of undefined React Router useRouteMatch issue

未关闭
#298 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
2.3k
派生
194
PR 合并指标
30 天内没有已合并 PR

描述

I can't solve this problem, "TypeError: Cannot read property 'location' of undefined " in my reactjs project. I am trying to nesting the url for blog post but not working it, and I have test it's math by console it's take the path but nesting showing error.

Below the code which I have tried but not solving

`
import React, { Component } from 'react';
import { Router, Link, Switch, useRouteMatch } from 'react-router-dom';
export default function Blogs(){
const match = useRouteMatch();
console.log(match.path)
return (





Latest Blogs




{/* */}







)
}

const PostListing = ()=> {
return (


)

}

const PostItem = (props) => {
return (





{""}






{props.postTitle}




Post Date: {document.lastModified}



)
}

///

`

贡献指南

这个仓库没有索引到贡献指南

调研方向

The error likely stems from using useRouteMatch outside a Router context. Check the project's routing setup to ensure the Blogs component is wrapped in a Router. Look at how redux-router integrates with React Router to see where the routing state is stored. Verify the component hierarchy and the version of react-router being used.

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, react
领域
frontend
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。