Vue component, prop is declared and passed, but console says prop is missing

Viewed 304

I'm working on creating reusable form inputs using vue + laravel.

I have one prop that is required, and I pass it and it renders as expected, but the console still logs the error:

"Vue warn]: Missing required prop: "inputId"".

Inspecting the vue element shows the prop as defined. Why is an error being generated while the the data is being passed?

Text Input Component

<template>
    <input type="text" :name="inputId" :id="cssid" :placeholder="placeholder" :value="value">
</template>

<script>
    export default {
        props: {
          inputId: {
            type: String,
            required: true,
          },
          isRequired: {
            type: Boolean,
            default: false,
          },
          placeholder: {
            type: String,
          },
          value: {
            type: String,
            default: '',
          },
        },

        mounted() {
            console.log('text mounted.')
        },

        computed: {
          cssid() {
            return this.inputId + '_selection';
          },
        },
    }
</script>

Fragment of blade view where component is being called (I've tried with title in quotes and not in quotes, no difference)

<text-input
  input-id="title"
></text-input>

Resultant html Result is correct, but why the error?

<input type="text" name="title" id="title_selection">

1 Answers

In this case, I had two instances of the component and I didn't realize the older one was there. The older one didn't have the prop declared and was giving the error, but it wasn't obvious in the console that I had loaded it twice. Removing the older instance of the component fixed the error.

Related