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.

FeatureRequest: Model for dynamically referencing icons

See original GitHub issue

What is the cleanest way to dynamically include an icon in a React component? eg when an icon name is passed as a prop to the component and the component needs to display the icon.

The structure of the packages do not lend themselves to import IconSet from '@iconify/icons-[set]' and use IconSet[iconname]

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
cyberaliencommented, Apr 3, 2020

Its not out of scope though 😃

I am working on Iconify version 2 right now. It is modular package that shares source with SVG framework, so it would be quite easy to implement React component with API. If you do want React component with API support, I can make one.

0reactions
cyberaliencommented, Jun 11, 2020

Forgot to mention: unlike SVG framework that uses simple JSONP to retrieve data from API, React component uses XMLHttpRequest. This is experimental thing. I’ll be testing how it works.

If you want to revert to JSONP behaviour, replace this line in src/icon.ts:

import { getAPIModule } from '@iconify/core/lib/api/modules/axios';

with

import { getAPIModule } from '@iconify/core/lib/api/modules/jsonp';

and rebuild package.

To rebuild package first in root directory run npm install and npm run bootstrap to install all dependencies and create links between packages, then in packages/react-with-api run npm run build to build it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create icon component dynamically and append it to element
I'm trying to create a dynamic icon component and append it to an element. I have a directive that creates a badge with...
Read more >
Feature request: IOS dynamic app icons | Voters - Expo
Since iOS 11.3, app can specify more app icons and can switch between them using code. It is quite easy, but requires bundling...
Read more >
Font Awesome 6 (beta) and dynamic icon name in Next JS
The way you import your icons uses a babel macro. It means that the referenced icon must be known at build time. It...
Read more >
Dynamic Icon for Garadget - Home Assistant Community
Hello HA Community, I have two Garadget Covers for my Garage which I love, however, I'm looking for a way to Dynamically change...
Read more >
Issues for Dynamic Entity Reference | Drupal.org
Title Status Priority Drupal Coding Standards Issues | phpcs Needs work Normal field_storage_dependencies Postponed (maintainer needs more info) Normal Use virtual index instead of triggers Active...
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