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

gatsby-plugin-google-gtag: OutboundLink ForwardRef #22704

Closed
cbravo opened this issue Mar 31, 2020 · 1 comment · Fixed by #22705
Closed

gatsby-plugin-google-gtag: OutboundLink ForwardRef #22704

cbravo opened this issue Mar 31, 2020 · 1 comment · Fixed by #22705

Comments

@cbravo
Copy link
Contributor

cbravo commented Mar 31, 2020

Summary

When using the OutboundLink component from gatsby-plugin-google-gtag I ran into an issue because the component does not forward its ref to the dom node inside.

Basic example

My exact use case was that I wanted to use a material-ui Link component and pass the OutboundLink as the actual component to be used like so:

import React from 'react';
import Link from '@material-ui/core/Link';
import { OutboundLink } from 'gatsby-plugin-google-gtag';

const ExternalLink = ({ to, ...props }) => (
  <Link
    component={OutboundLink}
    href={to}
    target="_blank"
    rel="noopener noreferrer"
    {...props}
  />
);

export default ExternalLink;

this throws an error because material-ui Links can only take components that can take refs and looking at the OutboundLink component shows that it cannot.

@cbravo
Copy link
Contributor Author

cbravo commented Mar 31, 2020

I created a PR here #22705

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

Successfully merging a pull request may close this issue.

1 participant