0

I have an array with objects before, I applied icons from fontAwesome as a value, it looked like this

const SideBarColors = [
   {
        IconStyle: {
            Icon: faDotCircle,
        }
   }
]

Then in another component I got this icon like this

<FontAwesomeIcon icon={SideBarStyle.Icon} />

Now I use a different approach (React Icons), the point is that now I create icons in this way

<BsBraces />

In this case, I cannot assign this icon inside the object as a value, it gives an error

IconStyle: {
    IconTitle: <BsBraces />
}

What should I do in this case?

4

1 回答 1

2

You just need to :

IconStyle: {
    IconTitle: BsBraces
}

without the </>

Apply it to JSX like:

<IconStyles.IconTitle />
于 2021-02-28T21:08:46.867 回答