Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

felloz's avatar

InertiaJs: Props undefined

I'm passing data to my component <Dashboard compo="Developer"> from my component Developer but im getting undefined in Dashboard

Developer.vue

<script setup>
import Dashboar from '@/Pages/Dashboard.vue';
</script>

<template>
<Dashboard compo="Developer">
				<!--Some Html-->
</Dashboard>
</template>

Dashbard.vue

<script setup>
defineProps({
		compo: String
});
</script>

<template>
<h1>{{ compo }}</h1> <!--getting undefined-->
</template>

How can I solve this?

0 likes
9 replies
tykus's avatar

You have almost got it…

<script setup>
let props = defineProps({
		compo: String
});
</script>

<template>
<h1>{{ compo }}</h1>
</template>

You need the props.compo within the script only

felloz's avatar

@tykus It dosnt work either. I know its a pretty simple and I did it several times without inertia but for some reason is not working

_fag's avatar

Try to remove the space arround the equal sign on your Dashboard tag.

And on your Dashboard component, you don't need the props variable. Just remove it.

<script setup>
defineProps({
    compo: String
});
</script>

<template>
    <h1>{{ compo }}</h1>
</template>
_fag's avatar

@felloz Ok. Have you checked to make sure you didn't type something wrong? Sometimes, rewrite a bit of code can help.

MohamedTammam's avatar

Why are you trying to send the component as a prop that way.

Use slots instead, or pass the component name but import it inside the parent component that will be using it.

felloz's avatar

You can delete this question.

The fool me was making the changes in a component hoping to see the results in another that had nothing to do with it. It took me almost an hour to figure it out.

1 like

Please or to participate in this conversation.