I'm passing data to the view like this.
$user = auth()->user();
return Inertia::render('Auth/Profile', [
'name' => $user->name,
'email' => $user->email,
'is_active' => $user->is_active,
'posts' => $user->posts,
]);
I would like to have the autocompletion for these props in the React Component, for example when I type props.posts
or props.is_active
it should autocomplete and gives type hints.
and also autocompletion for the auth
property, for example when type props.auth.
then the IDE should give me hint that there is a user
property on the props.auth
.
export default function Profile(props) {
const { data, setData, patch, processing, errors, reset } = useForm({
name: props.name,
email: props.email,
});
const currentUserName = props.auth.user.name;
// Currently I'm not getting any autocompletion or type hint.
// either I've to read documentation to know that there is a `user` property on the `auth`,
// or I've to inspect props using React Developer Tools browser extension. this back-n-forth reduces productivity easily.
}
What I used to do back in the blade.php days to get Autocompletion & Type Hints.
@php
/**
* @var App\Models\User $user
*/
@endphp
<div class="card-header">Dashboard</div>
<div class="card-body">
Your name {{ $user->name }}
<hr/>
@foreach($user->posts as $post)
@php
/**
* @var App\Models\Post $post
*/
@endphp
<div>
{{ $post->title }}
</div>
@endforeach
</div>
Additional context
I'm using Inertia Laravel & React adapter. and IDE is: Intellij Idea Ultimate.
Thanks for making this beautiful adapter, which eases full-stack development.