fisshy / react-scroll

React scroll component
https://github.com/fisshy/react-scroll/blob/master/README.md
MIT License
4.36k stars 437 forks source link

Putting Links and Elements in Separate Components?? #346

Open jonnydungeons opened 6 years ago

jonnydungeons commented 6 years ago

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

GainorB commented 6 years ago

I have the same issue

fisshy commented 6 years ago

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

jonathanadler commented 5 years ago

@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!

IsaacGluck commented 4 years ago

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

This didn't work for me

bretthayes commented 4 years ago

The following works. Tested with react-scroll@1.7.16.

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

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

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