MCPcopy Create free account
hub / github.com/QuarkGluonPlasma/react-course-code / App

Function App

react-threejs-app/src/App.jsx:7–41  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5import { useState } from 'react';
6
7function App() {
8
9 const changeHorseColorRef = useRef(() => {});
10
11 const [str, setStr] = useState('');
12
13 useEffect(() => {
14 const dom = document.getElementById('content');
15 const { changeHorseColor } = init(dom, setStr);
16
17 changeHorseColorRef.current = changeHorseColor;
18
19 return () => {
20 dom.innerHTML = '';
21 }
22 }, []);
23
24 return <div>
25 <div id="header">
26 React 和 Three.js
27 </div>
28 <div id="main">
29 <div id="content">
30 </div>
31 <div id="operate">
32 <button onClick={()=> {changeHorseColorRef.current('pink')}}>粉色</button>
33 <button onClick={()=> {changeHorseColorRef.current('lightgreen')}}>绿色</button>
34 <button onClick={()=> {changeHorseColorRef.current('lightblue')}}>蓝色</button>
35 </div>
36 <div>
37 {str}
38 </div>
39 </div>
40 </div>
41}
42
43export default App;

Callers

nothing calls this directly

Calls 3

useStateFunction · 0.90
useEffectFunction · 0.90
initFunction · 0.90

Tested by

no test coverage detected