In react you import whatever you need in each file. What is needed in every single page component?
Sep 12, 2022
6
Level 1
Global component in inertia-react
How do I go about adding a global component (e.g. Link) to the following inertia-react's createInertiaApp() method in Laravel 9?
import { Link } from '@inertiajs/inertia-react';
createInertiaApp({
title: (title) => `${title} - ${appName}`,
resolve: (name) => resolvePageComponent(`./Pages/${name}.jsx`, import.meta.glob('./Pages/**/*.jsx')),
setup({ el, App, props }) {
return render(<App {...props} />, el);
},
});
Level 102
@AndrewL64 you might be able to do some sort of trick to get that working, but that isnt how react is designed. And using it as a component from prop would most likely be more code than the import, and you would need it in every file
If you are using phpstorm you can just ask it to import it when you type it. Pretty sure vscode has something similar
2 likes
Please or to participate in this conversation.