Inertia.js child component props/data?

Viewed 703

Taking pingcrm as an example, can a child component receive data from its corresponding controller and not only the route controller?

For example, we have the routes:

Route::get('/', [DashboardController::class, 'index'])
    ->name('dashboard')
    ->middleware('auth')

Route::get('contacts', [ContactsController::class, 'index'])
    ->name('contacts')
    ->middleware('remember', 'auth')

If I embed <Contacts /> as a child component of the Dashboard, it doesn't receive any data from ContactsController.

Coming from a Vue background where I would ensure a component has the appropriate data inside the component itself for re-usability (e.g. a contacts table <ContactsTable /> that appears multiple times at different routes throughout the app), is this possible with Inertia.Js?

There is shared data but that doesn't seem ideal for most use cases and the documentation explicitly warns to use this sparingly as it is sent on every response.

What confuses me is that the controllers seem to be route bound rather than component bound, unless I am misunderstanding something?

0 Answers
Related