Use ci-vite-react only in a section of the page #27
Answered
by
vago-me
sanchawebo
asked this question in
Q&A
-
So I have an existing project in CI4 and want to include react in a section of a page (Which is possible according to the react docs). How do i achieve this? |
Beta Was this translation helpful? Give feedback.
Answered by
vago-me
Jul 25, 2023
Replies: 1 comment 1 reply
-
Got it to work like this: <?php
use Mihatori\CodeigniterVite\Vite;
echo $this->extend('templates/layoutFlaPo');
echo $this->section('content'); ?>
<div class="vite-wrapper">
<div id="app"></div>
</div>
<?= $this->endSection() ?>
<?php
echo $this->section('pageScripts');
$vite = Vite::tags();
echo $vite['js'] ?? null;
echo $this->endSection() ?> Is this the correct way of embedding vite-react into a page? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use Mihatori\CodeigniterVite\Vite; $vite = Vite::tags(); $vite['js'] ?? null;
extend('templates/layoutFlaPo') ?> section('content'); ?>Should be in the controller, like this.
in .env
VITE_AUTO_INJECTING=false