Skip to content

injection "icons" not found #40

@alinnert

Description

@alinnert

Current behavior

When using the <CIcon> component there's a [Vue warn] printed in the console: injection "icons" not found..

Expected behavior

No warning printed in the console if there's no "icons" injection.

Details

This happens because in the first line of the CIcon setup() function there's a call to inject('icons'). This gives a warning if there's no injection provided using provide('icons', ...). The documentation doesn't mention this, and also it's not necessary to do this since you can alternatively import an icon and pass it to <CIcon :icon="icon"> directly.

To prevent this warning there should be a default value provided like this: const icons = inject('icons', null). Then handle null accordingly.

Activity

ukjpw

ukjpw commented on Nov 14, 2023

@ukjpw

I am having the same issue. The icons are rendering fine, but there are 'injection "icons" not found.' warnings.

igoohd

igoohd commented on Feb 28, 2024

@igoohd

Same problem here.
In my Nuxt 3 app I temporally solved this issue passing a provide "icons" as null just to omit the console message.

app.vue file:

const nuxtApp = useNuxtApp()
nuxtApp.vueApp.provide('icons', null)

But, after I noticed that in my case I can not use string icons as props if I don't provide icons of @coreui/icons, since that I rewrote the code with:

import * as icons from '@coreui/icons'
const nuxtApp = useNuxtApp()
nuxtApp.vueApp.provide('icons', icons)
matgenois

matgenois commented on Apr 5, 2024

@matgenois

Same issue here

Ca-tt

Ca-tt commented on Feb 1, 2025

@Ca-tt

Same trouble. Any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @alinnert@matgenois@Ca-tt@igoohd@ukjpw

        Issue actions

          injection "icons" not found · Issue #40 · coreui/coreui-icons-vue