[HELP] how to handle react-perf/jsx-no-new-object-as-prop while passing array of styles to react native component?
See original GitHub issueSo, considering the code below, which is supposedly popular in react-native, how should I re-design my code to remove the warning?
<Text
style={[
styles.smallBoldText,
styles.greenText,
styles.greenBackground,
]}>
Some Text
</Text>
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Style - React Native
With React Native, you style your application using JavaScript. All of the core components accept a prop named style. The style names and...
Read more >Passing Functions to Components - React
There are several ways to make sure functions have access to component ... Make sure you aren't calling the function when you pass...
Read more >Pass style array to React Component - Stack Overflow
I want to pass an array of styles to a React Component using postcss-loader and css modules. My webpack.config.file for compiling css files...
Read more >Styles - 30 Days of React Native - Fullstack.io
React Native lets us pass an array of styles to a component to accomplish the same thing. When we pass an array of...
Read more >How To Style React Components | DigitalOcean
In this tutorial, you'll learn three different ways to style React components: plain Cascading Style Sheets (CSS), inline styles with ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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
styles
is passed as a prop or something you could useuseMemo
to memoize this array.Here we use with useMemo: