WARNING: Multiple instances of Three.js being imported

Viewed 2984

I'm getting the following warning when trying to use @react-three/fiber and @react-three/drei in the same project.

enter image description here

Steps to reproduce

npx create-react-app reproduced-warning
cd reproduced-warning
npm install three @react-three/fiber @react-three/drei

My src/App.js file looks like this:

import React from 'react';
import { Canvas } from '@react-three/fiber';
import { Stats } from '@react-three/drei';

import './App.css';

const App = (props) => {
  return (
    <div className="App">
      <Canvas />
    </div>
  );  
};

export default App;

To start the App run npm run start.

Module information

  • three at ^0.128.0
  • @react-three/fiber at ^6.0.16
  • @react-three/drei at ^4.2.0

Updated (4 May 2021)

Additional information

Did a bundle analysis and got the following results:

// Used these imports
import React from 'react';
import { Canvas } from '@react-three/fiber';
import { Stats } from '@react-three/drei';

enter image description here

// Used these imports
import React from 'react';
import { Canvas } from '@react-three/fiber';

enter image description here

Tried the same for the production build but it did not appear to have the duplicate three.module.js entry. It looks like this only happens in development, any idea why?

0 Answers
Related