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

custom styled function or decorator #454

Closed
eviL-ivan opened this issue Jul 7, 2019 · 2 comments
Closed

custom styled function or decorator #454

eviL-ivan opened this issue Jul 7, 2019 · 2 comments
Labels
needs: investigation 🔎 Issue has to be investigated for reason or solution

Comments

@eviL-ivan
Copy link

eviL-ivan commented Jul 7, 2019

Hi, linaria is awesome, but i try go from styled components to linaria and have a few troubles.
I don`t totaly undestand bug it or feature, please help me understand.

Do you want to request a feature or report a bug?

Maybe Bug

What is the current behavior?

For theming, so as not to pass theme in most of the components, i wanna decorate styled function, like this:

const myStyled = (Component) => withTheme(styled(Component));

But have a error:
Error: Using the "styled" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly. See https://github.com/callstack/linaria#setup

https://codesandbox.io/embed/hello-world-8bukp

and if i use linaria for style any named component, like this:

const RedButton = styled(Button)

i have error:
import React from "react";

but it normally work if i pass styled component(like styled.h1), or arrow func, like with:

const RedButton = styled(p=><Button {...p}/>)

https://codesandbox.io/embed/hello-world-bu9q8

If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.

https://github.com/zeit/next.js/tree/canary/examples/with-linaria

What is the expected behavior?

I can`t use styled in runtime, but i can use any decorators around styled func, for my goals, like auto theme passing.
And i can style any components with linaria, same with styled-components.

@jayu jayu added the needs: investigation 🔎 Issue has to be investigated for reason or solution label Mar 31, 2020
@jayu
Copy link
Contributor

jayu commented Mar 31, 2020

In Linaria, you cannot use the styled function without template string after. Without template string, it will not get transpiled by babel and will leave styled code in runtime.

It should work if you change to

const myStyled = (Component) => withTheme(styled(Component)``);

@jayu jayu closed this as completed Mar 31, 2020
@jayu
Copy link
Contributor

jayu commented Apr 28, 2020

I didn't understand the issue when I was closing it, but it's a duplicate of #447. Take a look on my comment with the solution #447 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: investigation 🔎 Issue has to be investigated for reason or solution
Projects
None yet
Development

No branches or pull requests

2 participants