Skip to content

Commit 700039d

Browse files
committed
add mounted boolean
1 parent fb1c0c4 commit 700039d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/App.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@ import './App.css';
22
import { ThreeWrapper } from './components/threeWrapper/ThreeWrapper';
33
import { useControls } from 'leva';
44

5-
/*
6-
This App.js conditionally adds/removes a ThreeWrapper component
7-
based on the threeLoaded state variable
8-
*/
9-
10-
function MyComponent() {
11-
const { speedX, speedY, scale } = useControls({
5+
function WrapperWithControls() {
6+
const { speedX, speedY, scale, mounted } = useControls({
127
speedX: {
138
value: 0.15,
149
min: 0,
@@ -27,16 +22,23 @@ function MyComponent() {
2722
max: 4,
2823
step: 0.1,
2924
},
25+
mounted: true,
3026
});
3127
return (
32-
<ThreeWrapper props={{ speedX: speedX, speedY: speedY, scale: scale }} />
28+
<>
29+
{mounted && (
30+
<ThreeWrapper
31+
props={{ speedX: speedX, speedY: speedY, scale: scale }}
32+
/>
33+
)}
34+
</>
3335
);
3436
}
3537

3638
function App() {
3739
return (
3840
<div className="App">
39-
<MyComponent />
41+
<WrapperWithControls />
4042
</div>
4143
);
4244
}

0 commit comments

Comments
 (0)