Всем привет, используя следующий подход, возникает ошибка.
index.js:1 Warning: [object Object]: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. ([url]https://fb.me/react-special-props[/url])
Подскажите пожалуйста как правильно её исправить ?
https://reactjs.org/docs/forwarding-refs.html
import React from "react";
const { useRef, forwardRef } = React;
const ComponentOne = forwardRef((props, ref) => {
return (
<div ref={ref}>
<div>ComponentOne</div>
</div>
);
});
const ComponentTwo = node => {
console.log(node);
return (
<div>
<div>ComponentTwo</div>
</div>
);
};
export const App = () => {
const node = useRef(null);
return (
<div>
<ComponentOne ref={node} />
<ComponentTwo node={node} />
</div>
);
};