-
Notifications
You must be signed in to change notification settings - Fork 5
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
[HELP] how to handle react-perf/jsx-no-new-object-as-prop while passing array of styles to react native component? #44
Comments
@TheSolly I don't know anything about React Native specifically but in the web version of react you could either create a constant outside of the component if these are all just static properties. If |
Both excellent suggestions, @bolatovumar. |
Understood, thanks a lot for explaning @bolatovumar 🙏 |
@TheSolly Yes, if React Native works in the same way as React for web then you should get some perf improvement if the component in question tends to re-render a lot. |
Here we use with useMemo: const textStyles = useMemo(() => [
styles.smallBoldText,
styles.greenText,
condition ? styles.greenBackground : null,
], [condition]);
return (
<Text
style={textStyles}>
Some Text
</Text>
); |
So, considering the code below, which is supposedly popular in react-native, how should I re-design my code to remove the warning?
The text was updated successfully, but these errors were encountered: