adeveloper
adeveloper

Reputation: 311

how to remove href attribute from element in reactjs

There is jsx element, all I need is remove 'href' attribute based on a value,

code below throws parsing error,

 <a
                  className={`nav-link ${item === active ? 'active' : ''}`}
                  data-mdb-toggle="tab"
                  {...{item.focus ? `href == '#active_tab'`}} // Parsing error: Unexpected token, expected ","                  role="tab"
                  aria-selected={item.name === active}
                >

how to fix it?

Upvotes: 1

Views: 207

Answers (1)

alisasani
alisasani

Reputation: 2968

your condition is not correct. change to below:

{... item.focus ? {href: '#active_tab'} : {}}

Upvotes: 2

Related Questions