I'm new to React
making a separate file for CSS
or
writing CSS in component style props
<div style={{maxWidth: '590px'}}></div>
I did both and looks like they are the same. I was wondering is there any disadvantages or side effects in this way?
I'm new to React
making a separate file for CSS
or
writing CSS in component style props
<div style={{maxWidth: '590px'}}></div>
I did both and looks like they are the same. I was wondering is there any disadvantages or side effects in this way?
Writing inline styling can bring up performance issues. Again it depends on your application. I will suggest checkout styled-components for this kind of scenario.
Definitely CSS file.
CSS is meant to be written freely and should have it's own place. In a css file you can see all the scoping you need (SCSS (Sass) is even better by the way, very suggested!), overrides of such and etc.
In addition, something you should keep in mind is CSS overrides - bad for performance.
With a separate CSS file you use class and id, and have such a better workspace for writing editing and debugging CSS.
Plus, inline css will override almost any other css rule you give the specific element - little dangerous.
Using inline CSS does not generate low performance, however, if you want to make a project as it would be done in a job as a developer, I recommend that you write your styles in separate files and if possible, with a css pre-processor such as Stylus , Sass or Less