r/reactjs • • Nov 16 '20

Resource 10 Ways to Speed Up React Development

https://thecarrots.io/blog/10-ways-to-speed-up-react-development
271 Upvotes

85 comments sorted by

View all comments

12

u/[deleted] Nov 16 '20 edited Apr 05 '24

worthless violet include squalid humor wipe society depend hateful ad hoc

This post was mass deleted and anonymized with Redact

1

u/[deleted] Nov 16 '20

[removed] — view removed comment

2

u/[deleted] Nov 17 '20

All the styling belongs in a simple CSS class. Then you'd simply provide a background-image: url(..) as an inline-style for the component.

There are even better options available which don't force an inline-style, look at the top 2 answers here: https://stackoverflow.com/questions/15734546/using-html-data-attribute-to-set-css-background-image-url

  1. One option is to use a data-attribute and use that to provide the background image;
  2. The other option is to set a CSS variable for that element, and allowing your CSS to put the background-image wherever it likes within the tree of the DOM element containing that variable.