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

2

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

I think you can't use JSX without importing react?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.