Skip to content

Commit c2d94c5

Browse files
authored
Chore/update deps (support React 19)
- Add support for React 19 - Update Getting started guide and readme - Update dependencies - Make required changes to code for latest versions of React and R3F - Disable performance widget in story books (for now) due to peer dependency to React 18 - Bump version for new release to npm
1 parent d9eb9da commit c2d94c5

File tree

17 files changed

+875
-1093
lines changed

17 files changed

+875
-1093
lines changed

README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,33 @@ This library has dependencies to the following libs:
3131
npm i videx-3d
3232
```
3333

34-
You also need to install the peer-dependencies:
34+
You also need to install the required peer-dependencies.
35+
36+
First, if not already installed, you'll need React version 18 or later:
3537
```
3638
// react
37-
npm i react@18 react-dom@18
39+
npm i react react-dom
40+
```
3841

42+
React Three Fiber (R3F):
43+
```
44+
// react three fiber
45+
npm i @react-three/fiber
46+
```
47+
Note that if using React 18, you need `@react-three/fiber` version 8.
48+
49+
Depending on your needs you might consider installing the following additional packages:
50+
```
3951
// three js
4052
npm i three
4153
42-
// react three fiber
43-
npm i @react-three/fiber
54+
// drei
55+
npm i @react-three/drei
4456
45-
// comlink
57+
// comlink - if using web workers
4658
npm i comlink
4759
```
48-
60+
Note that if using React 18, you need `@react-three/drei` version 9.
4961

5062
## Configure
5163
Rendering complex scenes in the browser (single threaded) can quickly become bottlenecked, degrading user experience. For this reason, most of the components have been decoupled from data management and processing, by depending on a _store interface_ and _generator_ functions. This allows the heavy work to be offloaded to web workers (but not required).

documents/getting-started.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@
22

33
## Creating a React app
44

5-
First, we need a basic React web application running. At the time being this must be React v18 due to missing support for v19 in peer dependencies.
6-
7-
To create a new React v18 app, you can use Next.js:
5+
First, we need a basic React web application running. Quickest and easiest way to do so it to use Vite:
86

97
```
10-
npx create-next-app@14
8+
npm create vite@latest my-app --template react
9+
cd my-app
10+
npm install
11+
npm run dev
1112
```
1213

13-
Please note that we have to use next version 14 for react v18!
14+
Note that we need react v18 or later, and typescript is recommended.
1415

1516
## Installing peer dependencies
1617

17-
Besides React, we will also need threejs, react three fiber and comlink:
18+
Besides React, we will also need to install react three fiber:
1819

1920
```
20-
npm install three @react-three/fiber comlink
21+
npm install three @react-three/fiber
2122
```
2223

2324
## Make a simple 3d scene
@@ -27,8 +28,6 @@ Before adding the `videx-3d` components library we should create a basic 3d scen
2728
In this example, we will be using typescript. We start by creating a new file for a component named "Test.tsx":
2829

2930
```tsx
30-
'use client' // <-- if using next
31-
3231
// Test.tsx
3332
import { Canvas } from '@react-three/fiber'
3433

@@ -47,10 +46,10 @@ export const Test = () => {
4746
Then import this file and render the Scene component in your app:
4847

4948
```tsx
50-
// page.tsx
49+
// App.tsx
5150
import { Test } from './Test'
5251

53-
export default function Home() {
52+
export default function App() {
5453
return (
5554
<div style={{ width: `100vw`, height: `100vh` }}>
5655
<Test />
@@ -308,10 +307,8 @@ We return a mesh element, this time passing the generated geometry as a prop to
308307
Let's replace the cubes from our earlier example with the new Tube component:
309308

310309
```tsx
311-
'use client' // <-- if using next
312310

313311
// Test.tsx
314-
315312
import { CameraControls } from '@react-three/drei'
316313
import { Canvas } from '@react-three/fiber'
317314
import { Tube } from './Tube'

0 commit comments

Comments
 (0)