react-cursor-position icon indicating copy to clipboard operation
react-cursor-position copied to clipboard

Props don't get passed if the child is a memo

Open boy51 opened this issue 3 years ago • 0 comments

Hi,

const Memo = React.memo(props => {
  console.log(props);
  if (!props.position) throw new Error("No position");
  return <div>Yolo</div>;
});

function App() {
  return (
         <ReactCursorPosition>
            <Memo />
          </ReactCursorPosition>
  );
}

The Memo component in the example will throw an error. If you remove the Memo, props get passed as expected.

Please forgive me if this is not a bug and rather a limitation of React.memo. But the way I see it, props should be passed regardless, no?

boy51 avatar Oct 01 '20 14:10 boy51