Advertisement
Guest User

Untitled

a guest
May 27th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. import React from 'react';
  2. import ScrollIntoViewIfNeeded from 'react-scroll-into-view-if-needed';
  3.  
  4.  
  5. const ToggleScrollComponent = () => {
  6. const [showDrilldown, setShowDrilldown] = React.useState(false);
  7.  
  8. return (
  9. <div className='wrapper'>
  10. <button onClick={() => setShowDrilldown(!showDrilldown)}>Show drilldown</button>
  11. {showDrilldown && (
  12. <ScrollIntoViewIfNeeded key={Math.random().toString()} options={{ behavior: 'smooth', scrollMode: 'always', }}>
  13. <div className='also could be component'>
  14. Hey there! Ya Scrolled!
  15. </div>
  16. </ScrollIntoViewIfNeeded>
  17. )}
  18. </div>
  19. );
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement