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

Create text variant defaults is not working. #157

Open
alphonse92 opened this issue May 5, 2022 · 12 comments
Open

Create text variant defaults is not working. #157

alphonse92 opened this issue May 5, 2022 · 12 comments

Comments

@alphonse92
Copy link

alphonse92 commented May 5, 2022

Restyle components do not use the default styles unless you specify itvariant="defaults" in the props.

My component looks like:

import {
  createRestyleComponent,
  createText,
  createVariant,
  color,
  spacing,
  typography,
  layout,
  createBox,
} from '@shopify/restyle';

export const Link = createRestyleComponent(
  [
    color,
    spacing,
    typography,
    layout,
    createVariant({themeKey: 'linkVariants'}),
  ],
  createText(),
);

The theme object variant looks like:
Screen Shot 2022-05-05 at 3 39 40 PM

Video showing the variant only working when I set variant="defaults"

Screen.Recording.2022-05-05.at.3.32.55.PM.mov

Version
Screen Shot 2022-05-05 at 3 41 27 PM

More info:

I created a wraper component to inspect the style object passed down by the restyle wraper. As you can see the first two outputs are printed when variant is undefined but the next two outputs shows are printed when variant="defaults"

image

@sbalay
Copy link
Contributor

sbalay commented May 6, 2022

Hey @alphonse92, could you try the following changes locally and see if they fix this issue? https://github.com/Shopify/restyle/pull/152/files

@alexanderblackh
Copy link

alexanderblackh commented May 13, 2022

Hey @alphonse92, could you try the following changes locally and see if they fix this issue? https://github.com/Shopify/restyle/pull/152/files

I wasn't able to try your solution, however, I can confirm I had a similar issue as the above poster, and downgrading to 2.0.0 solved it for me. When I upgraded to 2.1.0, the app would immediately crash if any Text components were on screen. The error code I got was:

Error: Value 'defaults' does not exist in theme['textVariants']

@ghost
Copy link

ghost commented May 26, 2022

I'm having the same issue. running restyle 2.1.0. Going to try to downgrade to 2.0.0

@alexanderblackh
Copy link

alexanderblackh commented Oct 7, 2022

I'm having the same issue. running restyle 2.1.0. Going to try to downgrade to 2.0.0

Can confirm I'm still having the same issue and this suggestion worked then and still works now.

@brijesh-aglowid
Copy link

Hey @alphonse92, could you try the following changes locally and see if they fix this issue? https://github.com/Shopify/restyle/pull/152/files

@sbalay Yes it is working, can we have this fix in the release branch?

@chj-damon
Copy link
Contributor

same here.

@alexanderblackh
Copy link

This is still broken, and in addition, #35 is now appearing in new apps as well, and both are resolved by downgrading to 2.0.0. It's a 50/50 of which of these issues appear in a new app I'm working on. At this point, I can only assume 2.1.0 is broken and has been for some time. Luckily 2.0.0 is fully stable, as I'm using this in 5 different apps and have been for a few months, so if anyone is using this library, make sure you yarn add @shopify/restyle@2.0.0

@mattfrances
Copy link
Contributor

Hey @alphonse92 and @alexanderblackh, I'm unable to reproduce locally. Are you still seeing this issue?

@BECkvalentine
Copy link

I have run into this issue using version 2.4.2

@rklf
Copy link

rklf commented Aug 31, 2023

I have run into this issue using version 2.4.2

Same. I get
Error: Value 'defaults' does not exist in theme['textVariants']
regardless I've a defaults or not. Version 2.4.2

@TarikOez
Copy link

Also having that problem in 2.4.2

@alexanderblackh
Copy link

Hey y'all, sorry for ghosting on this thread, I gave up sometime ago and found downgrading for my prior project provided what I needed. However, on a new project this re-appeared again that used an old theme.ts that outright lacked a defaults under the textVariants block. So if y'all see this error again, double-check you have it and it's spelled correctly.

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

No branches or pull requests

9 participants