【问题标题】:Warning: Expected `onClick` listener to be a function, instead got a value of `string` type警告:预期 `onClick` 侦听器是一个函数,而不是 `string` 类型的值
【发布时间】:2021-04-30 14:44:29
【问题描述】:
const TextInfoShiftBox: FunctionComponent<TextInfoShiftBoxInterface> = () => {
  
  const [stateArrow, setStateArrow] = useState(false);
  
  const handlerCollapseInfo = (e) => {
    e.preventDefault();
    setStateArrow(!stateArrow)
  };
  
  return (
    <AreaContainer>
      <div className='info-shift-box'>
        <Icon onClick={(e) => handlerCollapseInfo(e)} className='arrow-icon' size='20px' icon={stateArrow ? "be-110" : "be-030"} />
        <h3>Info</h3><Icon className='warm-icon' size='24px' icon={"bd-150"} />
      </div>
      <div>
      <b>text</b>
      <LinkContainer>
        <Link className='ref' text=' acá.' onClick="www.google.com.ar" type='red' />
      </ LinkContainer>
        <span className='info-shift-box-client'>
          &nbsp; other text.
          {stateArrow ? ' text' : ''}
        </span>
      </div>
    </ AreaContainer>
  )

【问题讨论】:

标签: reactjs


【解决方案1】:
onClick="www.google.com.ar"

上面是返回一个字符串,如果你想链接到某个地方你需要使用to方法:

<Link className='ref' text=' acá.' to="https://www.google.com.ar" type='red' />

【讨论】:

    猜你喜欢
    • 2021-04-26
    • 2019-05-29
    • 2017-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多