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

[sx] support function declaration #49

Closed
siriwatknp opened this issue May 3, 2024 · 1 comment
Closed

[sx] support function declaration #49

siriwatknp opened this issue May 3, 2024 · 1 comment
Labels
new feature New feature or request

Comments

@siriwatknp
Copy link
Member

siriwatknp commented May 3, 2024

Summary

A framework like Next.js transpile the code from ArrowFunction to FunctionDeclaration that developers don't have control:

 ⨯ unhandledRejection: SyntaxError: /Users/siriwatknp/practice-repos/nextjs-tailwind-v4/src/app/landing-page/components/Features.tsx: @pigment-css/react: sx prop only supports arrow functions directly returning an object, for example () => ({color: 'red'}). You can accept theme object in the params if required.
  171 |                             children: [
  172 |                                 /*#__PURE__*/ _jsxDEV(Box, {
> 173 |                                     sx: (param)=>{
      |                                                  ^
  174 |                                         let { theme } = param;
  175 |                                         return {
  176 |                                             backgroundSize: "cover",

The original code is:

<Box
  sx={({ theme }) => ({
    backgroundSize: 'cover',
    backgroundPosition: 'center',
    minHeight: 280,
    backgroundImage: 'var(--Image-light)',
    ...theme.applyStyles('dark', {
       backgroundImage: 'var(--Image-dark)',
    }),
  })}

The sx prop should work with function declaration too.

Examples

No response

Motivation

No response

Search keywords: sx function declaration

@siriwatknp siriwatknp added status: waiting for maintainer These issues haven't been looked at yet by a maintainer new feature New feature or request and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 3, 2024
@siriwatknp
Copy link
Member Author

I don't think we need this since #50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant