# How to integrate Threejs into React interface

**URL:** <https://discourse.threejs.org/t/how-to-integrate-threejs-into-react-interface/30826>\
**Category:** Questions\
**Tags:** react, threejs\
**Created:** [October 14, 2021, 3:57pm UTC](https://discourse.threejs.org/t/how-to-integrate-threejs-into-react-interface/30826 "2021-10-14T15:57:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kamyar\_Taher](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/kamyar_taher/32/31864_2.png) [@Kamyar\_Taher](https://discourse.threejs.org/u/Kamyar_Taher)\
**Post date:** [October 14, 2021, 3:57pm UTC](https://discourse.threejs.org/t/how-to-integrate-threejs-into-react-interface/30826/1 "2021-10-14T15:57:08Z")

</div>

Hello,

I want to integrate three js within the simulation tab in the image below.

 ![im2.PNG](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/5/f/5f85b807cc909dbdfc409d931e99efd873575171.jpeg)

I tried something, but it doesn’t work as I want.  
I have the following code for the “simulation” page.

```javascript
import React, { Component } from "react";
import ReactDOM from "react-dom";
import * as THREE from "three";

export default function Simulation() {
  class App extends Component {
    componentDidMount() {
    // three js code
    }
    render() {
      return <div ref={(ref) => (this.mount = ref)} />;
    }
  }
  const rootElement = document.getElementById("root");
  ReactDOM.render(<App />, rootElement);
}

```

And I obtain the following result when I click the simulation tab. The problem is that I want to keep the sidebar and all the other components of the page. I want the three js part to be like a “window” inside my react webpage.  
Moreover, I don’t know if it’s possible, but I want to also insert react component inside the three js window.

 ![im1](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/e/0/e00d010c64fd69677599ea38a3f440a20351c8df.png)

I’m new to react, three js and front end more generally, so I’m a bit lost. Thank you in advance for your answer.

---

<div class="post-metadata">

**Author:** ![marquizzo](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/marquizzo/32/25192_2.png) [@marquizzo](https://discourse.threejs.org/u/marquizzo)\
**Post date:** [October 14, 2021, 4:14pm UTC](https://discourse.threejs.org/t/how-to-integrate-threejs-into-react-interface/30826/2 "2021-10-14T16:14:48Z")

</div>

I believe this question has been asked a few times before: [Best way to integrate PLAIN Three.js inside a React app?](https://discourse.threejs.org/t/best-way-to-integrate-plain-three-js-inside-a-react-app/27049)
