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.

Wrapper component not working

See original GitHub issue

Hi, I’m trying to create a wrapper component as mentioned in #18 in order to get around the limitation of not being able to define a default prefix value, but it is not working. Here it is:

<template functional>
    <font-awesome-icon
            :icon="['far', icon]"
    ></font-awesome-icon>
</template>

<script>
    import FontAwesomeIcon from '@fortawesome/vue-fontawesome'

    export default {
        components: {
            FontAwesomeIcon
        },

        props: {
            icon: {
                type: String,
                default: ''
            }
        },
    }
</script>

It builds fine, but I am getting this error in console:

[Vue warn]: Unknown custom element: <font-awesome-icon> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

(found in <Anonymous>)

I am registering my wrapper in my main app.js file like this:

// Font Awesome
import {library} from '@fortawesome/fontawesome-svg-core'
import {far} from '@fortawesome/pro-regular-svg-icons';

library.add(far);

Vue.component('fa-icon', require('./components/FontAwesome'));

What am I doing wrong?

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
benjivmcommented, Aug 30, 2018

Ah I see… so this works now:

app.js

import {library} from '@fortawesome/fontawesome-svg-core';
import {far} from '@fortawesome/pro-regular-svg-icons';

library.add(far);

import {FontAwesomeIcon} from '@fortawesome/vue-fontawesome';

Vue.component('font-awesome-icon', FontAwesomeIcon);
Vue.component('fa-icon', require('./components/FontAwesome'));

./components/FontAwesome.vue

<template functional>
    <font-awesome-icon
            :icon="['far', props.icon]"
    ></font-awesome-icon>
</template>

I don’t like having to register the component twice, but if that’s what I gotta do to override the default prefix then I guess it’ll have to stay.

Thanks.

1reaction
robmadolecommented, Aug 29, 2018

Try import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'

Read more comments on GitHub >

github_iconTop Results From Across the Web

React wrapper component not working as expected
One issue I have with this is I want to use the useDropzone hook in both the Wrapper component and the MyDropzone component....
Read more >
[Bug][v6]: Could not use wrapper component around Route ...
I just ran into this problem as well. I'm seeing something even stranger where any component with a path and element property is...
Read more >
React wrapper component not working as expected-Reactjs
[Solved]-React wrapper component not working as expected-Reactjs. Search. score:1. function Wrapper({ children }) { const { getRootProps, getInputProps, ...
Read more >
How To Create Wrapper Components in React with Props
In this tutorial, you'll create wrapper components with props using the React JavaScript library. Wrapper components are components that ...
Read more >
Why Is styled-components "styled" Wrapper Not Working With ...
Fix for styled-components not applying styling to extended React component.
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