Ok, so I experimented, and it turned out that there are ways, and it is not as difficult as I thought. This can help those just starting out in React JS.
So, there are two ways to do this and two reasons for adding styles to a string:
(1) Add the class name inside the style attribute as an object so that it can be drawn inside a regular CSS stylesheet, directly inside a JSX file, or used for conditional CSS
EXAMPLE 1
const classNameAsAPlainObject = { color: '#333333', backgroundColor: '#999999' } <a href="#" className="an-existing-class" style={classNameAsAPlainObject} > Button </a>
EXAMPLE 2
const conditionIsSomething = { color: 'red' } <a href="#" className="an-existing-class" style={conditionIsSomething ? 'classNameBasedOnCondition' : ' ' }> Button </a>
In the second example, two different classes can be declared depending on the desired result, or one class can be declared if the condition is true or none if the condition is false.
(2) Add it to the regular className attribute where a condition is required, but it is mandatory to place existing class names and keep in mind that this method requires styling in a regular CSS file. If the condition is not required, add the class as normal to the className attribute.
EXAMPLE 3
<a href="#" className={"an-existing-class " + (conditionIsSomething ? 'thisClass' : 'thatClass')}> Button </a>
EXAMPLE 4
<a href="#" className={"an-existing-class " + (conditionIsSomething ? 'aClassIsAdded' : ' ')}> Button </a>
Again, if this condition requires it, one class can be declared or not, as shown in Example 4. Be sure to leave a space in any case after the โexisting classโ and before the closing quote, so that is the space for the conditional class.
So, I believe that the general rule is that you add a class and style as an object (as in examples 1 and 2), you can style it in a JSX file, but if you add the class name to the "className" attribute, you You will put it inside a regular CSS file. I have not experimented with this, so I will try. If anyone finds otherwise, please enlighten me.