html - How to add data attribute without value in react create element? -


i adding div dom below,

react.createelement("div", { classname: "test"});

the rendered html should below

<div class="test" data-test> </div> 

where can add data-test in createelement?

you can't because attribute without value means attribute has value true in jsx. don't pass data-test , this.props['data-test'] undefined in component. or if need have attribute empty value add default values in component definition.

defaultprops: {     'data-test': '' } 

Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -