# 'jsonforms' or 'dispatch' couldn't be injected. Are you within JSON Forms?

**URL:** <https://jsonforms.discourse.group/t/jsonforms-or-dispatch-couldnt-be-injected-are-you-within-json-forms/1302>\
**Category:** General\
**Created:** [February 7, 2023, 7:55pm UTC](https://jsonforms.discourse.group/t/jsonforms-or-dispatch-couldnt-be-injected-are-you-within-json-forms/1302 "2023-02-07T19:55:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CodeXiD](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/codexid/32/631_2.png) [@CodeXiD](https://jsonforms.discourse.group/u/CodeXiD)\
**Post date:** [February 7, 2023, 7:55pm UTC](https://jsonforms.discourse.group/t/jsonforms-or-dispatch-couldnt-be-injected-are-you-within-json-forms/1302/1 "2023-02-07T19:55:17Z")

</div>

Hello, thanks for your hard work.  
Unfortunately I’m having trouble migrating to jsonforms 3.0.0.  
My project is on nuxtjs (2). Here are my dependencies:

```auto
"@jsonforms/core": "3.0.0",
"@jsonforms/vue": "3.0.0",
"@jsonforms/vue2": "3.0.0",
"@jsonforms/vue2-vanilla": "3.0.0",
"nuxt": "2.16.0",
"vue": "2.7.0",
"vue-template-compiler": "2.7.0",

```

call jsonforms

```auto
<template>
    <div data-vue-component-name="FormBuilder">
        <JsonForms1
            ref="json-forms"
            :key="renderId"
            :data="value"
            :renderers="renderers"
            :schema="schema"
            :uischema="uiSchema"
            :ajv="ajv"
            :readonly="readonly"

            @change="$emit('change', $event)"
        />
    </div>
</template>

```

I am getting the following errors

```auto
[Vue warn]: inject() can only be used inside setup() or functional components.
[Vue warn]: inject() can only be used inside setup() or functional components.
'jsonforms' or 'dispatch' couldn't be injected. Are you within JSON Forms?

```

I also had to enter the following in the nuxt config

```auto
build: {
        extend(config) {
            config.module.rules.push({
                test: /\.js$/,
                exclude: {
                    and: [
                        /node_modules/,
                    ],
                    not: [
                        /@jsonforms/,
                    ],
                },
                use: {
                    loader: 'babel-loader',
                },
            });
            config.module.rules.push({
                test: /\.ajv$/,
                use: {
                    loader: 'babel-loader',
                },
            });
        },
    },

```

After that my project started to run but displays the above errors.

I also removed all my custom renderers from the array to exclude them from possible problems, but the error remained, only after I hid json-forms via v-if=“false” the error disappeared (oddly enough 🙂 )

I previously had jsonforms version 2.5.\* which worked fine, I decided to upgrade to the new version to get the “i18n” prop to replace “is a required property” under my inputs, if there is a way to do this without going to third version please let me know.

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [February 9, 2023, 7:49pm UTC](https://jsonforms.discourse.group/t/jsonforms-or-dispatch-couldnt-be-injected-are-you-within-json-forms/1302/2 "2023-02-09T19:49:02Z")

</div>

Hi!

Sadly I don’t have experience with Nuxt, so I’m not familiar with its specialties.

> Here are my dependencies: […]

You should not have `@jsonforms/vue` AND `@jsonforms/vue2`. They are mutually exclusive with `@jsonforms/vue` being based on Vue 3 and `@jsonforms/vue2` being based on Vue 2.

I could imagine that the errors are coming from this.

* * *

> if there is a way to do this without going to third version please let me know.

I would definitely recommend staying up to date with JSON Forms.

In JSON Forms 2.5 the main two ways to customize the error messages are:

- Use [`ajv-errors`](https://ajv.js.org/packages/ajv-errors.html). Note that for JSON Forms 2.5 we used Ajv v6, therefore you need to use ajv-errors v1. You can use the `createAjv `function exported from `@jsonforms/core` to create your Ajv instance, customize it with ajv-errors and then pass it as a prop to JsonForms.
- Use custom renderers
