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

Web experimentalCSSMediaQueries: fix when value is undefined #277

Closed
wants to merge 1 commit into from

Conversation

chr314
Copy link

@chr314 chr314 commented Sep 2, 2024

Summary

Using experimentalCSSMediaQueries on web, if the value is undefined it will crash

Copy link

vercel bot commented Sep 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-unistyles-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 2, 2024 1:53pm

@jpudysz
Copy link
Owner

jpudysz commented Sep 2, 2024

Hey, can you give me some context? When it happens?

@chr314
Copy link
Author

chr314 commented Sep 9, 2024

Hello,
in this example if the param color is undefined and experimentalCSSMediaQueries is enabled then it will crash

const stylesheet = createStyleSheet(theme => ({
    container: (color) => ({
        backgroundColor: color,
    }),
}));

my workaround is to use a default value like

 backgroundColor: color || '#fffffff',

@jpudysz
Copy link
Owner

jpudysz commented Sep 9, 2024

Interesting!
Thanks for the details. I will try to repro & review PR

@jpudysz
Copy link
Owner

jpudysz commented Oct 1, 2024

Hmm I've tested your example, and used experimentalCSSMediaQueries: true, but passing undefined as a color is not crashing an app.

My code:

const stylesheet = createStyleSheet(theme => ({
    example: (color: string) => ({
        backgroundColor: undefined
    })
}))

Stylesheet is attached to single View:

<View style={styles.example()} />

Without experimentalCSSMediaQueries:

No class name, no inline styles, deault class .css-view-175oi2r

With experimentalCSSMediaQueries, default class .css-view-175oi2r.

.css-view-175oi2r {
    align-items: stretch;
    background-color: rgba(0, 0, 0, 0);
    // other styles
}

Tried with few other props, but with no luck to reproduce.

Do you have more context, or better example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants