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

How to useRestyle with custom variants in Restyle 2.0 #147

Closed
HurrellT opened this issue Apr 7, 2022 · 5 comments
Closed

How to useRestyle with custom variants in Restyle 2.0 #147

HurrellT opened this issue Apr 7, 2022 · 5 comments

Comments

@HurrellT
Copy link

HurrellT commented Apr 7, 2022

Hi! I'm building a component lib creating variants for my components.

I'm creating variants like this:

const inputVariants = createVariant<Theme, 'inputVariants'>({
  themeKey: 'inputVariants',
});

then using useRestyle to inject the styles in the corresponding section of my component like this

  const InputStyle = useRestyle([inputVariants, spacing], {
    variant: currentVariant,
    ...remainingStyles,
  });

Now, with restyle update 2.0, useRestyle is not working with variants, even after being wrapped with composeRestyleFunctions and I'm not finding the way to make it work. Am I using it incorrectly?

Thanks!

@HurrellT HurrellT changed the title How to useRestyle with custom variants in Restyle 2.0 How to useRestyle with custom variants in Restyle 2.0 #question Apr 7, 2022
@HurrellT HurrellT changed the title How to useRestyle with custom variants in Restyle 2.0 #question How to useRestyle with custom variants in Restyle 2.0 Apr 7, 2022
@sbalay
Copy link
Contributor

sbalay commented Apr 11, 2022

@HurrellT Could you create and share a repo with the code and instructions to reproduce the unexpected behaviour you describe?

@HurrellT
Copy link
Author

HurrellT commented Apr 12, 2022

Hi @sbalay ! I made a repo with an example of what I'm expecting to do.
https://github.com/HurrellT/restyleVariantsExample
Thanks!

@sbalay
Copy link
Contributor

sbalay commented Apr 19, 2022

Thanks for that @HurrellT!

I've created a PR to your repo with a workaround, would you mind playing around with that and letting us know if you still face any issues?

@fortmarek
Copy link
Contributor

Closing as stale.

@isaachinman
Copy link

@fortmarek Is there any example in the documentation anywhere of how to achieve this?

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

4 participants