0

I have some html in variable

export const PropertyDesign = {
 clubhouse: `<i class="fas fa-utensils icon-property"></i>`,
 gymnasium: `<i class="fas fa-dumbbell icon-property"></i>`,
 swimingPool: `<i class="fas fa-swimming-pool icon-property"></i>`,
 joggingTrack: `<i class="fas fa-running icon-property"></i>`, 
 playArea: `<i class="fab fa-playstation icon-property"></i>`
}

Which I want to use in JSX of my javascript, I initially tried this

    <p> {PropertyDesign[feature]} </p>

Where feature is my key.

but this is displaying like this in my page. Any idea how I can display icon instead of markup?

enter image description here

Nald Dev
  • 479
  • 4
  • 13
anny123
  • 5,060
  • 11
  • 50
  • 95

1 Answers1

2

Remove the template string represetation from the object:

export const PropertyDesign = {
 clubhouse: <i className="fas fa-utensils icon-property"></i>,
}

Using template strings would just render it as string and not JSX.

Also, use className in JSX

Agney
  • 16,443
  • 6
  • 45
  • 68