道具验证中缺少 'prop'?
'prop' is missing in props validation?
我是 React 的 forwardRef 的新手,我需要帮助。我在 FadeContents
中的道具上遇到错误,例如道具验证中缺少 'direction'。有针对这个的解决方法吗?我觉得我必须在某处定义道具才能在 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
我是 React 的 forwardRef 的新手,我需要帮助。我在 FadeContents
中的道具上遇到错误,例如道具验证中缺少 'direction'。有针对这个的解决方法吗?我觉得我必须在某处定义道具才能在 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