nuka-carousel
nuka-carousel copied to clipboard
ref值为字符串在react 16.4.1中报错
问题描述:如题,使用了antd-mobile之后carousel组件报错。 环境:macos 10.13.6,react 16.4.1 修复方式:参考FormidableLabs/nuka-carousel中ref的写法,更改为回调函数的方式。 具体报错内容为: invariant.js:42 Uncaught Error: Element ref was specified as a string (slider) but no owner was set. This could happen for one of the following reasons:
- You may be adding a ref to a functional component
- You may be adding a ref to a component that was not created inside a component's render method
- You have multiple copies of React loaded See https://fb.me/react-refs-must-have-owner for more information. at invariant (invariant.js:42) at coerceRef (react-dom.development.js:11887) at reconcileSingleElement (react-dom.development.js:12589) at reconcileChildFibers (react-dom.development.js:12645) at reconcileChildrenAtExpirationTime (react-dom.development.js:13016) at finishClassComponent (react-dom.development.js:13213) at updateClassComponent (react-dom.development.js:13156) at beginWork (react-dom.development.js:13825) at performUnitOfWork (react-dom.development.js:15864) at workLoop (react-dom.development.js:15903)