![](/img/trans.png)
[英]How to use react-error-boundary package with a component that is wrapped with forwardRef()
[英]Check if a React component is wrapped by forwardRef
是否有內置方法可以知道組件是否已經用React.forwardRef
包裝?
test(React.forwardRef(() => null))
function test(c) {
const isForwardRef = ???
if (!isForwardRef) {
c = React.forwardRef(c)
}
// ...
}
使用來自react-is
的isForwardRef
function 。
import {isForwardRef} from 'react-is'
isForwardRef(c)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.