【问题标题】:how to resolve overload errors in reactjs如何解决reactjs中的重载错误
【发布时间】:2021-11-15 13:29:08
【问题描述】:
import React from 'react'
import { Link } from 'react-scroll'
import "./Protocol.css"
import { ANALYTICS, TRADE, USERS, TRADERS, VOTES, ZEROES } from "../../Constants"
const Protocol = () => {
    return (
        <div className="Protocol_container">
            <div className="Protocol_heading">
                {ANALYTICS}
            </div>
            <div className="Protocol_content">
                <Link>
                    <p>{ZEROES}</p>{TRADE}
                </Link>
                <Link >
                    <p>{ZEROES}</p>{USERS}
                </Link>
                <Link >
                    <p>{ZEROES}</p>{TRADERS}
                </Link>
                <Link>
                    <p>{ZEROES}</p>{VOTES}
                </Link>
            </div>

        </div>
    )
}
export default Protocol

犯错

没有重载匹配这个调用。 Overload 1 of 2, '(props: LinkProps | Readonly): Link',给出了以下错误。 类型 '{ children: (string | Element)[]; 中缺少属性 'to' }' 但在“只读”类型中是必需的。 重载 2 of 2,“(道具:LinkProps,上下文:任何):链接”,给出了以下错误。 类型 '{ children: (string | Element)[]; 中缺少属性 'to' }' 但在“只读”类型中是必需的。

【问题讨论】:

  • 只需将属性to 添加到您的Link
  • 您需要在您的Link 组件中添加to 属性。例如:&lt;Link to: '/home'&gt;.

标签: javascript reactjs typescript react-hooks react-scroll


【解决方案1】:

链接需要prop to="where to go",如果你想无处可去,只需使用to="#"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-08-04
    • 2021-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-20
    • 1970-01-01
    • 2016-04-07
    相关资源
    最近更新 更多