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

useStyleSheet seems to return different objects #1823

Open
renatomserra opened this issue Jul 8, 2024 · 0 comments
Open

useStyleSheet seems to return different objects #1823

renatomserra opened this issue Jul 8, 2024 · 0 comments

Comments

@renatomserra
Copy link

renatomserra commented Jul 8, 2024

Hi,

i am using useStyleSheet for my styles and themes.
I recently started using "Why did you Render" lib to detect why my app is becoming slower.
One reason seems to be that style object ids changing on each render is making components that shouldnt rerender, end up rerendering.
Is there any way to avoid this happening?

export const MyText = ({
  value,
}) => {
  const styles = useStyleSheet(themedStyles);
  
    return (
    <Layout style={styles.wrapper}>
        <Text style={styles.text}>{{value}}</Text>
        <Text style={styles.text}>{{`i also re-render`}}</Text>
    </Layout>
  );
};

const themedStyles = StyleService.create({
  text: {
    fontSize: 20,
  },
  wrapper: {
  marginTop: 30,
  })
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

1 participant