Horje
handling scrolling on react router transitions Code Example
handling scrolling on react router transitions
import { useEffect } from 'react';
import { withRouter } from 'react-router-dom';

function ScrollToTop({ history }) {
  useEffect(() => {
    const unlisten = history.listen(() => {
      window.scrollTo(0, 0);
    });
    return () => {
      unlisten();
    }
  }, []);

  return (null);
}

export default withRouter(ScrollToTop);




Javascript

Related
express handlebars html code Code Example express handlebars html code Code Example
javascript function that make a choice Code Example javascript function that make a choice Code Example
sleep js Code Example sleep js Code Example
github pages react route Code Example github pages react route Code Example
js sort string array Code Example js sort string array Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8