Giter VIP home page Giter VIP logo

Comments (13)

adrian-novacescu avatar adrian-novacescu commented on July 26, 2024 1

@nmn, I will try to do it until Friday. Worst case scenario I will do it during weekend.

from stylex.

nmn avatar nmn commented on July 26, 2024

Could you share the code that is causing the error? The null check was needed for some other edge-cases we ran into.

from stylex.

adrian-novacescu avatar adrian-novacescu commented on July 26, 2024

I have the same issue after updating. I updated from 0.4.1 to 0.6.1. I didn't try other versions. I can try to create a test case in 2 weeks if needed.

from stylex.

nmn avatar nmn commented on July 26, 2024

@adrian-novacescu Would you be willing to share a minimal repro? Ideally, start removing all the StyleX styles from your project until you find the root cause of the problem.

Thanks! (Sorry I was away for a couple of weeks)

from stylex.

adrian-novacescu avatar adrian-novacescu commented on July 26, 2024

Unfortunately I didn't have the chance to work on it and the next couple of weeks seems to be extremely busy. Sorry for that. I will notify you as soon as I can do it :(.

from stylex.

nmn avatar nmn commented on July 26, 2024

@adrian-novacescu If you can even share the last few files where you used StyleX I might be able to find the root cause.

from stylex.

EvgeniyLyakhov avatar EvgeniyLyakhov commented on July 26, 2024

@nmn in my case code below throws same error when I use storybook

import * as stylex from "@stylexjs/stylex";

export const spacing = stylex.defineVars({
    3: '12px',
});

const styles = stylex.create({
    optionBase: {
        padding: `0 ${spacing['3']}`, // this line
    },
});

from stylex.

nmn avatar nmn commented on July 26, 2024

@EvgeniyLyakhov just to verify. But is spacing defined in a separate file with the .stylex.js file extension and imported from there when being used in the stylex.create?

from stylex.

adrian-novacescu avatar adrian-novacescu commented on July 26, 2024

@nmn sorry it took me so long but I was full until now. I added a zip here that contain a test case where this can be reproduced. From what I see, it doesn't matter where the values are defined. As long as we use template literals for concatenating, it will fail. With normal string concatenation it works ok.

In the same test case I added another issue. I tried to use dynamic styles or variables for media queries but in this case I get: Only static values are allowed inside of a stylex.create() call.

All you need is to uncomment the code from index.tsx and run yarn production to reproduce that.

stylex.zip

from stylex.

nonzzz avatar nonzzz commented on July 26, 2024

According the minimal reproduction. I got the code before pipe to stylex compiler.

image
AFAIK. Dynamic style only support arrow function expression. So cause the error translate. So i disable the @babel/preset-env in your local babel.config.js and i got the right code for stylex.
image

@nmn Did you think it's a bug or a configuration error?

from stylex.

nonzzz avatar nonzzz commented on July 26, 2024

About StringLiteral being converted i'll take a look.

from stylex.

nonzzz avatar nonzzz commented on July 26, 2024

About babel configuration. I think we can add a document that describes its behavior to help users avoid incorrect configurations.

from stylex.

nmn avatar nmn commented on July 26, 2024

Thanks for understanding and then fixing this issue @nonzzz !

from stylex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.