L
L
lookingfor22020-08-19 22:44:49
React
lookingfor2, 2020-08-19 22:44:49

How to properly style react components?

There is a react application divided into components. The task sounds like this: Connect style files in .tsx files only in those that are required.
How to do it right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
McBernar, 2020-08-19
@lookingfor2

Keep the css file in the folder with the component. Import it into the component and write it as in the usual html.
Another option is to use module css. Not so convenient anymore, but there is a local scope.
The third option is styled components. There are small limitations, but in general, as I understand it, this option is used by many.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question