reactjs - Add custom HTML attributes with no value to JSX -


i have html needs custom attributes no value dependent on situation.. example these valid:

<div classname="playlist-row" selected> <div classname="playlist-row" active>    <div classname="playlist-row"> 

i tried doing like

let customattr = {'active'};  // incorrect syntax let customattr = {'active': true};  //doesn't work let customattr = {'active': ''};  //doesn't work  <div classname="playlist-row" {...customattr}> 

any ideas of how can work?

i believe should - in render() function:

render() {     let customattr = "active"      return (         <div classname={"playlist-row " + customattr}>     ) } 

or alternately, avoid string concatenation...

<div classname={`playlist-row ${customattr}`}> 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -