-
Notifications
You must be signed in to change notification settings - Fork 672
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
Using Link from Theme-UI and Gatsby throws an error #867
Comments
Yep, so this error isn’t library-related, that’s just a JavaScript issue, since you can’t have multiple variables with the same name. I usually do this: import { Link } from 'gatsby'
import { jsx, Link as A } from 'theme-ui' Using I think this issue can be closed 👍 |
@spaut Happy to help, though it looks like your last comment has some missing words, specifically the code. Can you show the code you’ve got? |
Yep. import { Link } from "gatsby"
import { jsx, Link as A } from 'theme-ui' Here are the element options:
In the above case, the link works but it isn't picking up the theme-ui style
In that case, the style is picked up, but now it no longer functions as a link: Gatsby isn't converting the element to an anchor tag with an href.
In the above case, I get the style and the link works, but of course now it's just a normal anchor tag with an href, not a Gatsby . |
Got it. I use Next.js primarily, where you wrap Next’s Link around Theme UI’s Link, but I just opened a CodeSandbox & it looks like if you’re using the Theme UI JSX pragma you imported, it just works, and you don’t need the component from Theme UI at all: More info in the docs, here: https://theme-ui.com/recipes/gatsby-link |
@lachlanjc Right, I can style the way you did (using I was trying to have the I think I realized my mistake. Since it should happen by default, I didn't need to import Essentially I want all the If there's a better approach than using BaseStyles, let me know. Also, sorry if this is the wrong spot for this kind of thing. I couldn't find a Spectrum specifically for Theme UI. |
Ah, got it. <A as={Link} to=“/about”>Automatically styled!</A> https://codesandbox.io/s/serverless-sun-j4vyc?file=/src/pages/index.js:301-351 |
Awesome. That actually works better for this case. Thanks, @lachlanjc ! |
I'm getting a webpack error when trying to use Gatsby's Link component and style it with theme-ui.
Throws this error:
Expected behavior
Seems like you should be able to style links with theme-ui.
The text was updated successfully, but these errors were encountered: