Giter Club home page Giter Club logo

Comments (7)

dev-cj avatar dev-cj commented on May 20, 2024 1

@dani-mp It seems to work fine. I tried this locally with the latest develop branch.

theme-ui1.mp4

from theme-ui.

dani-mp avatar dani-mp commented on May 20, 2024 1

Let's close the issue then. Thanks a lot for your insight! πŸŽ‰

from theme-ui.

dani-mp avatar dani-mp commented on May 20, 2024

@dev-cj interesting, it wasn't working for us 5 months ago and I don't see anything has changed in the Flex component implementation. Maybe it did somewhere else (e.g. emotion)?

Could you put that in a codesanbox so I can play with it?

from theme-ui.

dani-mp avatar dani-mp commented on May 20, 2024

@dev-cj btw, this is the implementation, the sx prop is overwritten and then spread. If you spread a fn inside an object, you get nothing.
image

What am I missing?

from theme-ui.

dev-cj avatar dev-cj commented on May 20, 2024

@dev-cj interesting, it wasn't working for us 5 months ago and I don't see anything has changed in the Flex component implementation. Maybe it did somewhere else (e.g. emotion)?

Could you put that in a codesanbox so I can play with it?

Sure, here you can check https://codesandbox.io/s/zealous-star-7thpek

@dev-cj btw, this is the implementation, the sx prop is overwritten and then spread. If you spread a fn inside an object, you get nothing. image

What am I missing?

Yes sx prop is overwritten and then spread there, but there theme-ui's transpiler executes the sx props instead of the reac babel runtime, so even if you try to log the sx props that are passed into the flex component you will not see the function in the props.

To see the function in logs try logging in parseProps here

from theme-ui.

dani-mp avatar dani-mp commented on May 20, 2024

Thanks, yeah it works!

I didn't know that the theme-ui transpiler was kicking in before the sx prop was computed. Or you said instead? I was assuming that first everything was compiled down to basic JavaScript, and then as a final/later step, the sx prop was converted into something else, and removed from the final props. I guess I still don't really know how this works because it doesn't make sense to me that depending on whether your prop is sx or not, the semantics of the JavaScript you're writing changes.

And in any case (there's probably a way to double check this), it seems that the implementation of Flex hasn't changed during these months since I created the issue (end of last year), but a colleague and I did find this issue in our codebase and verified that Flex wasn't working with a function, and Box was. Maybe the implementation of the runtime itself suffered a regression for some time? I even mentioned this in the description of the issue:

Maybe this was working before? We recently made a significant upgrade to one of our projects that was using quite an old version of theme-ui and noticed that some components broke because of this bug.

I didn't write the original code and I was suspicious that it never worked before, the team would have caught it for sure, and it only surfaced till we migrated to the by then current version of theme-ui.

from theme-ui.

dev-cj avatar dev-cj commented on May 20, 2024

Yeah, it could be some core changes or conflicts with other dependencies have caused the regression.

from theme-ui.

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.