React Native 警告:forwardRef渲染函数只接受两个参数:props和ref,你忘记使用ref参数了吗?native base

sshcrbum  于 6个月前  发布在  React
关注(0)|答案(3)|浏览(317)

我有这个警告当启动一个新的expo native base js项目native base 3.2.0 expo 4.12.0每个包都很好没有问题当运行项目时有这个错误:-

at node_modules/react/cjs/react.development.js:315:4 in printWarning
at node_modules/react/cjs/react.development.js:287:16 in error
at node_modules/react/cjs/react.development.js:1424:13 in forwardRef
at node_modules/native-base/src/components/composites/Skeleton/SkeletonCircle.tsx:12:20 in <global>
at node_modules/native-base/src/components/composites/Skeleton/index.tsx:3:0 in <global>
at node_modules/native-base/src/components/composites/index.ts:37:0 in <global>
at node_modules/native-base/src/index.tsx:7:0 in <global>
at App.js:2:0 in <global>
at node_modules/expo/AppEntry.js:3:0 in <global>
at http://packager.gi-qyq.anonymous.my-furniture.exp.direct/node_modules/expo/AppEntry.bundle?platform=android&dev=true&hot=false&minify=false:202324:3 in global code````

字符串

insrf1ej

insrf1ej1#

将native-base更新为3.2.1。

"dependencies": {
     "native-base": "^3.2.1"  
},

字符串

5w9g7ksd

5w9g7ksd2#

你在使用react-navigation 6.x吗?如果是的话,试着使用钩子,比如useRoute,useNavigation,而不是把它们作为props传递。

bq9c1y66

bq9c1y663#

我认为这个问题与native-base无关。forwardRef是用于从父组件访问子DOM元素的钩子。您不能将ref作为props发送给子组件。您必须在子功能组件中设置forwardRef钩子,其中包含props和ref。

//Child Component
const Child = forwardRef(({name},ref) => {
return(
<p>{ref.current}</p>
)}

字符串

相关问题