Skip to content

Commit

Permalink
Upgrade to React 18 (#192)
Browse files Browse the repository at this point in the history
* Use React 18 createRoot API

* Update to latest version of react (18)

* Make styleci happy
  • Loading branch information
kjoedion authored Sep 27, 2022
1 parent 9177349 commit 91ae7b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Console/InstallsInertiaStacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ protected function installInertiaReactStack()
'autoprefixer' => '^10.4.2',
'postcss' => '^8.4.6',
'tailwindcss' => '^3.1.0',
'react' => '^17.0.2',
'react-dom' => '^17.0.2',
'react' => '^18.2.0',
'react-dom' => '^18.2.0',
] + $packages;
});

Expand Down
6 changes: 4 additions & 2 deletions stubs/inertia-react/resources/js/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import './bootstrap';
import '../css/app.css';

import React from 'react';
import { render } from 'react-dom';
import { createRoot } from 'react-dom/client';
import { createInertiaApp } from '@inertiajs/inertia-react';
import { InertiaProgress } from '@inertiajs/progress';
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
Expand All @@ -13,7 +13,9 @@ 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);
const root = createRoot(el);

root.render(<App {...props} />);
},
});

Expand Down

0 comments on commit 91ae7b7

Please sign in to comment.