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

Document new limitation from #1794 #1799

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions website/packages/docs/src/pages/limitations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,27 @@ For more details, refer to the [Github Issue](https://github.com/atlassian-labs/

Media queries and other at-rules are sorted deterministically when stylesheet extraction is turned on. See [this page](/media-queries-and-other-at-rules) for more details of how the sorting works and what its limitations are.

## Returning static values from a dynamic property

Styled components that use functions to dynamically assign properties, such as in the example below, may face issues where these properties are incorrectly resolved to a static value based on the first return statement:

```jsx
const Component = styled.li({
boxShadow: (props) => {
if (props.isSelected) {
return '0 0 0 1px magenta';
}
return '0 0 0 1px green';
},
});
```

In this scenario, the result will always include a box shadow with the first static value `'0 0 0 1px magenta'`, and the function itself will not be executed at runtime. Consequently, any logic defined within the function will be ignored. This behavior occurs specifically when the function's first return statement provides a static value (e.g., a plain string).

The simplest workaround is migrating to a ternary, eg. `props.isSelected ? '0 0 0 1px magenta' : '0 0 0 1px green'`, but in general the usage of dynamic styles is effectively deprecated, see [no-dynamic-styles eslint rule](https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-dynamic-styles/usage) for better practices.

For more details, refer to the [Github Issue](https://github.com/atlassian-labs/compiled/issues/1794).

## Unsupported features

Below is a non-exhaustive list of features that Compiled does not support. Some are features we would like to add to Compiled at some point in the future, while others are features that we don't plan to implement.
Expand Down
Loading