Ad

Create Class In ReactJs Using JSX

- 1 answer

I want to create class in React using JSX. I have a dashboard built on react. I selected a part and through inspect element (Google developer console) I got the react id. Now, I want to create a class using JSX, like class=newclass . I have plan to use it in further CSS. I can insert manually from template. But, I want to do it through JSX, also want to test from console temporarily by running the code fron console. This is present area :-

<label data-reactid=".0.b.1.0.1.1.0.0.0.0.0.0">This is text</label> 

and I want to add a class there using JSX,

<label data-reactid=".0.b.1.0.1.1.0.0.0.0.0.0" class="newclass">This is text</label> 

Ad

Answer

Try this:

<label className='newclass'>This is text</label>
Ad
source: stackoverflow.com
Ad