Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically Load Font Awesome Icon From API #165

Open
cblaze22 opened this issue Sep 25, 2023 · 2 comments
Open

Dynamically Load Font Awesome Icon From API #165

cblaze22 opened this issue Sep 25, 2023 · 2 comments

Comments

@cblaze22
Copy link

If we want to dynamically build a menu with icons through a web api, is it possible to reference 'faMugSaucer' as a string to a component like below?

import { View } from 'react-native'
import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome'
import { faMugSaucer } from '@fortawesome/free-solid-svg-icons/faMugSaucer'

type Props = {}
export default class App extends Component<Props> {
  render() {
    return (
      <View>
        <FontAwesomeIcon icon={ faMugSaucer } />
      </View>
    )
  }
}```
@Gautammer
Copy link

is there any update?

@Gautammer
Copy link

@cblaze22 ok i solved by this:

import { FontAwesomeIcon } from '@fortawesome/react-native-fontawesome';
import { library } from "@fortawesome/fontawesome-svg-core";
import { fab } from '@fortawesome/free-brands-svg-icons';
import { far } from '@fortawesome/free-regular-svg-icons';
import { fas } from '@fortawesome/free-solid-svg-icons';

library.add(fab, far, fas);

<FontAwesomeIcon icon={'any-fa-name-string'} />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants