Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropdown as Gatsby Link not working #3224

Closed
jpeterson opened this issue Oct 16, 2018 · 3 comments
Closed

Dropdown as Gatsby Link not working #3224

jpeterson opened this issue Oct 16, 2018 · 3 comments
Labels

Comments

@jpeterson
Copy link

Bug Report

Steps

Use this project with GatsbyJS, augmenting Dropdown as Gatsby's Link. It is possible this is an issue with Gatsby Link, not this project.

import { Link } from 'gatsby'
import { Dropdown } from 'semantic-ui-react'
...

<Dropdown as={Link} to="/products" text="Products">
...
</Dropdown>

Expected Result

Dropdown should render as a Link without any warnings or errors.

Actual Result

Produces the following warning and doesn't navigate to routes without a page reload.

Warning:

Warning: GatsbyLink: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://fb.me/react-special-props)

Version

0.82.5

Testcase

NOTE: I was unable to reproduce this using @reach/router (which Gatsby's Link is wrapping). Both codesandboxes are below.

Not working with gatsby (see console on page load):
https://codesandbox.io/s/818n63rm8j

Working as expected with @reach/router:
https://codesandbox.io/s/2wzyo0qvw0

@welcome
Copy link

welcome bot commented Oct 16, 2018

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you've completed all the fields in the issue template so we can best help.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

@layershifter
Copy link
Member

I'm not sure that it's real valid usage at all, it also breaks styling.

In the future releases we will forward ref by default, #2844. However, workaround can be done with forwardRef API:

const ForwardedLink = React.forwardRef((props, ref) => (
  <Link {...props} innerRef={ref} />
));

Working Codesandbox: https://codesandbox.io/s/30oypqv2zp

@jpeterson
Copy link
Author

Thanks for the workaround @layershifter! I think styling works as expected as long as you have the item and simple props on the Dropdown.

Working Codesandbox (with style): https://codesandbox.io/s/818n63rm8j

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants