react-scroll icon indicating copy to clipboard operation
react-scroll copied to clipboard

Putting Links and Elements in Separate Components??

Open jonnydungeons opened this issue 6 years ago • 5 comments

I use this component in my menu component to scroll to page content which is in a different component. Is this possible?

jonnydungeons avatar Aug 18 '18 20:08 jonnydungeons

I have the same issue

GainorB avatar Sep 03 '18 23:09 GainorB

Yes, add an id to that component, and target that one in your scrolling.

fisshy avatar Sep 04 '18 06:09 fisshy

@fisshy I was wondering the same as J0NNYZER0.

In case I have a <Link to="someElement">click</Link> inside one component, and a <Element name="someElement">...</Element> inside a different component, and I don't want to use animateScroll , is this possible?

Btw, awesome library 💪 , thanks!

jonathanadler avatar Mar 26 '19 13:03 jonathanadler

Yes, add an id to that component, and target that one in your scrolling.

This didn't work for me

IsaacGluck avatar Apr 07 '20 21:04 IsaacGluck

The following works. Tested with [email protected].

// Menu Component
import { Link } from 'react-scroll';

<Link to="section">Section</Link>
// Section Component
import { Element } from 'react-scroll';

<Element name="section"></Element>

bretthayes avatar Apr 30 '20 19:04 bretthayes