簡體   English   中英

道具驗證中缺少“道具”?

[英]'prop' is missing in props validation?

我是 React 的 forwardRef 的新手,我需要幫助。 我在FadeContents的道具上遇到錯誤,它指出道具驗證中缺少例如“方向”。 有針對這個的解決方法嗎? 我覺得我必須在某處定義道具才能在 div 元素中使用它們,但我似乎無法理解在哪里? TIA!

// @flow

import React, { forwardRef } from "react"
import type { Node } from "react"

type Props = {
  direction: 'left' | 'right',
  animatingOut: boolean,
  children: Node,
}

const FadeContents = forwardRef<Props, HTMLDivElement>(
  ({ direction, animatingOut, children }, ref) => (       // <-- error here
    <div
      aria-hidden={animatingOut}
      animatingOut={animatingOut}
      direction={direction}
      ref={ref}
    >
      {children}
    </div>
  )
)

FadeContents.displayName = 'FadeContents'

export default FadeContents

我想這是來自 eslint 的錯誤? 但這有幫助嗎?

({ direction, animatingOut, children }: Props, ref) => ( // <-- error here

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM