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

stylex.create Errors thrown when defining only null values in a declaration #344

Closed
RimanDk opened this issue Jan 12, 2024 · 4 comments
Closed

Comments

@RimanDk
Copy link

RimanDk commented Jan 12, 2024

The problem
Style objects that include only entries with null values result in stylex.create should never be called. It should be compiled away. exception.

How to reproduce
Steps to reproduce:

  1. Create a React + TypeScript project with StyleX
  2. Create a style block/declaration including only null values, f.ex:
const styles = stylex.create({
  test: {
    padding: null,
  }
});
  1. Apply to any node in a given component

Code Sandbox example (expand console in the browser window - might need a reload to show up)

Expected behavior
Declared styles should be applied and no errors should be thrown

Environment (include versions). Did this work in previous versions?
Tested with 0.3.0 and 0.4.1 in a Vite project, using an unofficial StyleX Vite plugin didn't work with either version.

@nmn
Copy link
Contributor

nmn commented Jan 13, 2024

This seems like a bug with vite-plugin-stylex-dev, although I'm not sure what the issue might be since things do work when I add any other style.

To verify, I tried using vite-plugin-stylex which is another unofficial plugin. After manually forcing the plugin to use v0.4.1 of the stylex babel plugin, it seemed to work correctly even with just a single null style.

Here's a fork for your codesandbox example to see it working.


Side note: Thank you for providing a reproduction in your issue. It greatly helps me in debugging the issue.

@nmn nmn closed this as completed Jan 13, 2024
@RimanDk
Copy link
Author

RimanDk commented Jan 15, 2024

This seems like a bug with vite-plugin-stylex-dev, although I'm not sure what the issue might be since things do work when I add any other style.

To verify, I tried using vite-plugin-stylex which is another unofficial plugin. After manually forcing the plugin to use v0.4.1 of the stylex babel plugin, it seemed to work correctly even with just a single null style.

Here's a fork for your codesandbox example to see it working.

Side note: Thank you for providing a reproduction in your issue. It greatly helps me in debugging the issue.

Thank you for the quick response! Sounds very reasonable - I will raise the issue with the plugin makers, then. Cheers.

I wrestled briefly with the other plugin you mentioned, but couldn't get it to work in my setup. Unfortunately, the fork you provided appears to be a 1:1 with my own example and is still using vite-plugin-stylex-dev.

@nmn
Copy link
Contributor

nmn commented Jan 15, 2024

@RimanDk Sorry about the link mixup. This should be the correct one.

@RimanDk
Copy link
Author

RimanDk commented Jan 16, 2024

@RimanDk Sorry about the link mixup. This should be the correct one.

Many thanks 🙏

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

No branches or pull requests

2 participants