0

I want to move to the area of my parents when I click on Nav's menu. I think the code is roughly right, but it doesn't work. also, I want to use useRef from react-hooks.

//nav.js
const Nav = ({ moveScroll }) => {

  const handleMove = () => {
    moveScroll.current.scrollIntoView({ behavior: 'smooth' });
  };

  return (
 <Project to='' onClick={handleMove}>PROJECT</Project>
);
}
//app.js
const App = () => {
 const moveScroll = useRef();

return(
<ProjectTitle ref={moveScroll}>Project</ProjectTitle>
);
}
skyboyer
  • 19,620
  • 7
  • 50
  • 62
min
  • 3
  • 1
  • You either match the prop name moveScroll: `...`. Or if you go for `ref` prop for your custom component, use React.forwardRef. See duplicated answer for examples. – Dennis Vash Jan 24 '22 at 12:29

0 Answers0