question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Ionic/React IonIcons not working by setting name property

See original GitHub issue

Bug Report

Ionic version:

[Ionic/React] 4.11.0

Current behavior:

According to IonIcons documentation, icons should be able to set up by providing name property. Some of icons shows up by using this technique, most of them does not work (they don’t show up)

Expected behavior:

Icons be displayed by setting up name property, like <IonIcon name="star" slot="start" />

Steps to reproduce:

  • Create a simple Ionic/React app using the steps mentioned at https://ionicframework.com/blog/announcing-ionic-react/

  • npm i -g ionic

  • ionic start my-react-app

  • Pick “React” ad frontend framework

  • Pick “sidemenu” as starter template

  • Run ionic serve to start your app

  • Open http://localhost:8100 to run the app on the browser

  • Open sidemenu and click on “List” option

  • See there is a list with a bunch of items with icons

  • Now go to the source code, open file /my-react-app/src/pages/List.tsx

  • Find line 41 and replace icon={icons[x - 1]} for name="arrow-back"

  • Check each of items on the list display the arrow back icon

  • Go to the same line and now use other icons, like home or star

  • See none of those icons are displayed and no errors are displayed on the console

Related code:

This display arrow back icon correctly

<IonIcon name="arrow-back" slot="start" />
Screen Shot 2019-10-16 at 12 15 22 AM

This does not display neither home or star icon

<IonIcon name="home" slot="start" />
<IonIcon name="star" slot="start" />
Screen Shot 2019-10-16 at 12 16 23 AM

Other information:

Keep enabled the option to set up icons as strings is very important, specially for app/components that use their icons as strings configured on a database for instance, or on a config file.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
kingwill101commented, Oct 31, 2019

would be nice if this is mentioned in the docs.

1reaction
ElNinjaGaidencommented, Oct 16, 2019

That’s not what the documentation say. If that’s the case, why the property still exists? Totally a bummer given the use case I mentioned.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ionicons Usage Guide
When using icons in Ionic Framework you can specify different icons per platform. Use the md and ios attributes and provide the platform...
Read more >
The Correct Way to Use Ionicons in Your React Project
You cannot use ion-icon in ReactJS. In React, all component names must start with an uppercase letter, cannot include hyphens, and must be...
Read more >
'ionicons/icons' does not contain an export named 'star'
I created the app firstly by npx creat-react-app then installed ionic-react on that. The icon was not showing on th file.
Read more >
Upgrading to Ionic 6 | Ionic Documentation
Follow this guide to upgrade your Ionic 5 apps to Ionic 6. ... If you are also using setupConfig , pass your config...
Read more >
Custom SVG Icons in Ionic with Ionicons - Josh Morony
The performance benefit of only loading visible icons is something you get for free, but in this tutorial, I am going to walk...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found