Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react scroll reset in component

  const componentRef = useRef(null);

  const handleClick = () => {
    componentREf.current.scrollTo(0, 0);
  };

  return (
    <div ref={componentRef}>
    ...
      <button onClick={handleClick}> Reset scroll </button>
    </div>
    )
 
PREVIOUS NEXT
Tagged: #react #scroll #reset #component
ADD COMMENT
Topic
Name
7+7 =