Reactjs 来自字典的React-NavLink href映射不起作用?

Reactjs 来自字典的React-NavLink href映射不起作用?,reactjs,reactstrap,Reactjs,Reactstrap,我正在尝试将我的值从字典映射到NavLink字段。出于某种原因,这种精确的方法与react按钮完美配合使用,但与NavLink配合使用时却无法实现 我的字典有键和值,它们是包含两个值的列表:Name和URL。比如说 const links = { key1: ["key1Name", "key1URL"], key2: ["key2Name", "key2URL"] } 我用这个函数映射到我的导航链

我正在尝试将我的值从字典映射到NavLink字段。出于某种原因,这种精确的方法与react按钮完美配合使用,但与NavLink配合使用时却无法实现

我的字典有键和值,它们是包含两个值的列表:Name和URL。比如说

const links = {
    key1: ["key1Name", "key1URL"],
    key2: ["key2Name", "key2URL"]
}
我用这个函数映射到我的导航链接

{Object.values(links).map((key, index) => ( 
    <div className="centered">
        <NavLink className="splashButton" href={key[1]}>{key[0]}</NavLink>
    </div>
))}
{Object.values(links).map((键,索引)=>(
{key[0]}
))}
虽然这适用于我的按钮映射,但当我尝试使用NavLink时,我在href中得到了一个奇怪的错误,而对于按钮,我没有得到相同的精确代码

No overload matches this call.
  Overload 1 of 2, '(props: NavLinkProps | Readonly<NavLinkProps>): NavLink<unknown>', gave the following error.
    Type 'string | Element' is not assignable to type 'string | undefined'.
      Type 'Element' is not assignable to type 'string'.
  Overload 2 of 2, '(props: NavLinkProps, context: any): NavLink<unknown>', gave the following error.
    Type 'string | Element' is not assignable to type 'string | undefined'.ts(2769)

index.d.ts(1933, 9): The expected type comes from property 'href' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<NavLink<unknown>> & Readonly<NavLinkProps> & Readonly<...>'
index.d.ts(1933, 9): The expected type comes from property 'href' which is declared here on type 'IntrinsicAttributes & IntrinsicClassAttributes<NavLink<unknown>> & Readonly<NavLinkProps> & Readonly<...>'
没有与此调用匹配的重载。
重载1/2'(props:NavLinkProps | Readonly):NavLink'给出了以下错误。
类型“string | Element”不可分配给类型“string | undefined”。
类型“Element”不可分配给类型“string”。
重载2/2'(props:NavLinkProps,context:any):NavLink'给出了以下错误。
类型“string | Element”不可分配给类型“string | undefined”。ts(2769)
index.d.ts(1933,9):预期的类型来自属性“href”,该属性在类型“IntrinsicatAttributes&IntrinsicClassAttributes&Readonly&Readonly”中声明
index.d.ts(1933,9):预期的类型来自属性“href”,该属性在类型“IntrinsicatAttributes&IntrinsicClassAttributes&Readonly&Readonly”中声明

有人知道为什么会发生这种情况,以及我如何修复这种情况吗?

导航链接组件需要一个
to
道具,而不是
href

。。。

参考资料:

我的问题是,在地图上使用reactstrap导航链接时,它会禁用我的链接,使其不可单击。当对react router dom NavLink使用
to
时,它仅适用于内部链接,而我的所有链接都是外部链接
href
既不使用导航链接,也不使用链接,甚至不使用普通的
标记。