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

[v3] Animated.Text emits warning for array styles #512

Open
jeremybarbet opened this issue Jan 21, 2025 · 0 comments
Open

[v3] Animated.Text emits warning for array styles #512

jeremybarbet opened this issue Jan 21, 2025 · 0 comments

Comments

@jeremybarbet
Copy link
Contributor

jeremybarbet commented Jan 21, 2025

Description

Hi there,

If I have the following code

index.tsx

const Index = () => (
    <TextComponent name="Some text" style={s.text} />
);

const s = StyleSheet.create(theme => ({
  text: {
    color: theme.primary,
  },
}));

TextComponent.tsx

export const TextComponent = ({ name, style }: TextComponentProps) => (
  <Animated.Text style={[s.wrapper, style]}>{name}</Animated.Text>
);

const s = StyleSheet.create(theme => ({
  wrapper: {
    color: theme.primary,
  },
}));

it will emits Unistyles: we detected style object with 2 unistyles styles. This might cause no updates or unpredictable behavior. Please check style prop for "Text" and use array syntax instead of object syntax. [Component Stack]

If changing to

export const TextComponent = ({ name, style }: TextComponentProps) => (
-  <Animated.Text style={[s.wrapper, style]}>{name}</Animated.Text>
+  <Text style={[s.wrapper, style]}>{name}</Text>
);

It doesn't emit any warnings anymore, but obvisously reanimated doesn't work anymore

Steps to Reproduce

  1. Follow this PR https://github.com/jeremybarbet/unistyles-sandbox/pull/1/files
  2. You can also clone the repository [email protected]:jeremybarbet/unistyles-sandbox.git and run the app on the repro/animated.text branch

Snack or Repository Link (Optional)

https://github.com/jeremybarbet/unistyles-sandbox

Unistyles Version

3.0.0-nightly-20250121

React Native Version

0.76.6

Platforms

iOS

Expo

Yes

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

No branches or pull requests

2 participants