Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import ScrollIntoViewIfNeeded from 'react-scroll-into-view-if-needed';
- const ToggleScrollComponent = () => {
- const [showDrilldown, setShowDrilldown] = React.useState(false);
- return (
- <div className='wrapper'>
- <button onClick={() => setShowDrilldown(!showDrilldown)}>Show drilldown</button>
- {showDrilldown && (
- <ScrollIntoViewIfNeeded key={Math.random().toString()} options={{ behavior: 'smooth', scrollMode: 'always', }}>
- <div className='also could be component'>
- Hey there! Ya Scrolled!
- </div>
- </ScrollIntoViewIfNeeded>
- )}
- </div>
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement